Site Meter Tux Watch » Blog Archive » Linux command line

Linux command line

by Jeff Christman

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)
    » Jeff-Christman

Technology Channel Posts

  • Microsoft's intention to buy DataAllegro, Inc.
    On July 24th, Microsoft announced that it intends to acquire DATAllegro Inc., a provider of breakthrough data warehouse appliances. The acquisition will extend the capabilities of Microsoft’s [...]
  • 5 ways to speed up your PC
    Free up disk space By freeing disk space, you can improve the performance of your computer. The Disk Cleanup tool helps you free up space on your hard disk. The utility identifies files that you [...]
  • New Blogger for Microsoft Talk
    Hello Hello! My name is Brick ONeil, and i've been with the 451 Press Network since March 2007. I'm the new blogger for Microsoft Talk. We'll be discussing 'About Microsoft' itself. What's [...]
  • New blogger for Microsoft Office!
    Hello, my name is Brick ONeil and I'm the new blogger for Microsoft Office here on the 451 Press Network. I've been with 451 Press for a year and half, starting with Encouraging Health and enjoy [...]
  • Come Back Monday
    [...]
  • Changing Computers (Part 9)
    By: Mr JM Once you have all the needed in hardware, in drivers for the hardware and in software installation disks or downloads, things are ready to roll. With Windows installed on the machine, the [...]
  • Changing Computers (Part 8)
    By: Mr JM For my situation, it’s not as drastic as having to freeze the hard drive. And we have a home network to connect a number of computers so transferring the data is easier than having to [...]
  • So You Want to Be a Blogger – Part Four
    So you want to be a blogger and it’s time to choose a blog host. But who? You could go with what all your friends are going with, but what if you’re the first one to start a blog? Or what if [...]
  • So You Want to Be a Blogger - Part Three
    So you want to be a blogger and it’s time to choose a blog host. But who? You could go with what all your friends are going with, but what if you’re the first one to start a blog? Or what if [...]
  • So You Want to Be a Blogger - Part Two
    So you want to be a blogger and it’s time to choose a blog host. But who? You could go with what all your friends are going with, but what if you’re the first one to start a blog? Or what if [...]

Hot Off The Press

  • Five Sleeping Giants: Receivers
    When you call someone a sleeper, it can be a very subjective term. So for the sake of this post, we will narrow it down to this: Someone who can exceed the expectations of the masses and turn into a [...]
  • Weeds: "The Love Circle Overlap"
    So we've accused Rescue Me of making it up as it goes along, but this strikes me as ten times worse. Like, do they write these episodes after the previous one airs? Everything just ends abruptly and [...]
  • The Terrell Owens (Circa 2005) Effect: Five Receivers To Avoid
    We have all over-drafted a player a year too late, a year too early, under the wrong circumstances and sometimes we were just lacking the appropriate information. These are five players to avoid [...]
  • Into every life . . .
    A little rain must fall . . . but with that rain comes a rainbow if you are blessed to see it. This is a shot from the front door Sunday. We'd been having hints of rain all day, but it was mostly [...]
  • Jorge Garcia: Best Supporting Actor
    Congratulations to Jorge Garcia for winning the Best Supporting Actor trophy at the ALMA awards, the Latino oriented awards show held over the weekend. Jorge bested four other actors in this [...]
  • Chronicling change
    I just had a clever thought. I can celebrate the Olympics and go back to a project I started ages ago and ran out of steam on. I hate running out of steam. I especially hate the little energy I [...]
  • It Ain't Fair, I Tell Ya, It Just Ain't Fair!
    I have really enjoyed watching gymnastics during the Olympics, but I hate the judging system. Despite rules and points systems, it remains subjective at best. But I can deal with that... heck, if [...]
  • How an old tomato plant saved my sanity
    Due to a mid-life crisis need to change my life for the better I moved at the beginning of June.  My new home is much nicer, more comfortable and less stressful, but not a day has passed that I [...]
  • Milo Ventimiglia Talks ‘Heroes’ to CBR
    Comic Book Resources posted the first of a three part interview with Heroes star Milo Ventimiglia.  Milo talks about Season 3 and addresses some of the criticism of Season 2, especially [...]
  • The 99th Monkey by Eliezer Sobel - Author Virtual Book Tour
    Join Eliezer Sobel, author of the memoir, The 99th Monkey: A Spiritual Journalist's Misadventures with Gurus, Messiahs, Sex, Psychedelics, and Other Consciousness-Raising Adventures (Santa Monica [...]