Site Meter Tux Watch » Blog Archive » Linux command line

Linux command line

by

Linux has come a long way in the past two years. Today much of what needs to be done on a Linux machine can be done using a mouse and a little pointing and clicking. Occasionally, however, there are things that still require a little under-the-hood tinkering, where a rudimentary understanding of the command line comes in handy.

In response to regular comments from readers who ask for more detail on the commands we use in articles, Tectonic has put together our top eight list of must know command line tools. The list is not exhaustive and certainly not comprehensive, but if you know these commands you’ll convince most of the people most of the time that you’re a Linux guru.

< !-more-->
1: sudo/su

su is for switching users, usually to switch to the root user. sudo is a shorthand way of executing a command as the root user without needing to log in as root. Linux is a true multiuser system with each user having their own account and set of access privileges. The superuser or administrator account is called the ‘root’ account.

Today’s modern Linux systems usually force users to create non-root users when first installing, which is a sensible precaution. Running a system as root is potentially fatal because it is remarkably easy to break something by executing a wrong command. And as root, the system can’t protect the users from themselves. There are times, however, when it is important to be the root user - when installing software for example - and a way to switch to root temporarily is provided by sudo.

To use sudo do this:

sudo command you want to execute

You will be prompted for a password. You don’t need the root password. Just type in your password and the command will be executed as root. Once the command is done you will be returned to your own login.

su is a more permanent solution in which you are able to switch to another user for a whole session. To use type in su username you want to switch to and provide the password of the user when prompted. You will then have the privileges of the other user. To return to your own login type exit.

2: ls

One thing you’ll always need to do at the command line is list the contents of directories. ls does exactly this. ls is similar to the dir command on Windows and DOS. It lists all the files and directories in the current directory. ls /usr/share/ will list the contents of the /usr/share directory.

3: mv/cp

Something else you’re going to need to do is move and copy files from one directory to another. This is where mv and cp come in handy.

mv file1.txt /usr/share/ will move the file file1.txt to the /usr/share directory. mv *.txt /usr/share/ will move all the files with the .txt extension to the /usr/share directory.

To rename file1.txt as file2.txt mv file1.txt file2.txtcp works exactly as mv does except that is duplicates the file. So cp file1.txt /usr/share/ will copy file.txt to the /usr/share directory and keep a copy in the current directory as well.

4: cd

cd is the change directory command you’ll need to switch from one directory to another. Typing in cd /usr/share for example will switch you to the /usr/share directory. To get back to your home directory type in cd ~/. The tilde sign (~) represents your home directory.

5: man

man stands for manual. Most commands in Linux have a built-in manual entry. So next time you’re confused about how to use a command type in man command which will bring up the description of the command and its various options. Try man cp for example.

6: less/more

less and more do essentially the same thing: they display the contents of a file. less file1.txt will print out the contents of file1.txt in the terminal window a screenfull at a time. Use the spacebar or the arrow keys to navigate up or down the file.

7: locate

locate is a speedier way than find to find files on your Linux system. There is a caveat, however. Locate works so quickly because the filesystem is indexed ahead of time. Most Linux systems are set up to run updatedb at regular intervals which does the indexing.

locate filename or portion of filename will find the various files you are looking for, so long as they have been indexed. If there are pages of results use the more command to display them one screenfull at a time: locate filename | more.

The ‘|’ is called a pipe and it effectively filters the results of one command (in this case ‘locate’) through a second command (’more’ in the example’).

8: tar

Many of the files you will download for Linux will be compressed using a combination of tar and gzip. The files will most likely look something like filename.tgz or filename.tar.gz.

tar creates an archive of a number of files and gzip compresses the archive. To decompress these types of files do this: tar -zxvf filename.tgz which will decompress the file and pull the contents out of the archive file.

Did You Enjoy this Post? Subscribe to Tux Watch. It's Free!

One Response to “Linux command line”

  1. lalbotVorgo Says:

    Honestly, I believe I was regarding in pudgy with Damon. The carrying was fascinating.

Leave a Reply


About Tux Watch

Are you tired of Windows crashing , removing spyware, viruses, and proprietary lock-in? Are you frustrated with licensing fees and software activation demands? Are you dreading the arrival of Windows Vista, with its increased hardware requirements? Are you willing to try something different?

Tux Watch will search the web for the best resources of software, top articles and tips and even have tutorials to get you started. Linux is a free and open-source operating system that has seen tremendous growth in the past several years. Linux is stable, secure, and very powerful. It is also has tremendous capabilities, far beyond those available with other operating systems. .

Tux Watch Author(s)

Technology Channel Posts

  • Cell Phones + Social Networks = Love?
    [caption id="attachment_262" align="alignnone" width="128" caption="Social Networks"][/caption]Wireless industry ready to interface with Facebook, MySpace and Bebo Everybody at this week's Mobile [...]
  • LG X120 Netbook
    LG Electronics has announced it is launching their newest netbook called the LG X120. The laptop is a cute one with only 10.1″ screen with backlit. Powering it is an Intel Atom processor [...]
  • Uniea Haptique HardShell Case for MacBook
    This hardshell cases for the new MacBook aluminum are made of ABS plastic coupled with soft touch coating. It offers a textured feel, almost leather like, and protects the surface of the laptop [...]
  • Haier shows off it's offerings to the masses
    [caption id="attachment_1757" align="alignnone" width="600" caption="Haier netb ook, G1 and G2"][/caption]The fine folks over at Haier shows off mysterious "NetBooks," Android phones Haier's [...]
  • Hackers target Gamers
    [caption id="attachment_887" align="alignnone" width="128" caption="Xbox"][/caption]Although I'm not a gamer, everyone should be aware of hackers and malware. According to microsoft, What's the [...]
  • Microsoft Equips Individuals With New Training Resources Needed for Jobs
    [caption id="attachment_733" align="alignnone" width="109" caption="Microsoft"][/caption]Second time around for this bit of news, but very apropos in today's business climate. Microsoft Corp. [...]
  • LG Phone's Transparent Keypad Expected to "Make A New Fashion Statement"
    [caption id="attachment_259" align="alignnone" width="950" caption="Transluscent Phone"][/caption][caption id="attachment_258" align="alignnone" width="500" caption="LG GD-900"][/caption]Firmware or [...]
  • Preorder Nokia N86 at Expansys
    [caption id="attachment_1754" align="alignnone" width="162" caption="Nokia N86"][/caption]Engadget breaks this story: European markets can expect to see Nokia's N86 handset on or about July 22, [...]
  • Microsoft Tests Vista SP2, Readies Windows 7 Updates
    [caption id="attachment_884" align="alignnone" width="116" caption="Vista"][/caption]Lots coming out of Redmond these days. Service Pack 2 for Windows Vista and Windows Server 2008 is reportedly [...]
  • Five Steps to an E-friendly Résumé
    [caption id="attachment_730" align="alignnone" width="128" caption="Resume on Outlook"][/caption]With today's economy and layoffs, we all need all the help we can get when searching for jobs. MSN [...]

Hot Off The Press