Command Line Primer

Linux is a very powerful operating system. But a lot of its power comes from the command line interface (cli). Starting off the CLI is a bit more difficult because you have to know the commands in order to get started, but once you have a handle on the commands the CLI is no more difficult and sometimes easier than a gui interface. First lets look at how to browse the file system and look at the contents of the file system.

If you open the terminal and type pwd you should see /home/username. PWD essentially lists the working directory that you are currently in; by default the terminal dumps you in your home directory. Your home directory is often abbreviated by ~. Alright so if I wanted to browse to the root (/) directory I simply need to type in cd /. If you type that command in and then hit pwd it should look like this:

root@m-ubuntu-vm:/# cd /
root@m-ubuntu-vm:/# pwd

Once you are here type ls to list the directories.
root@m-ubuntu-vm:/# ls
bin dev initrd lib mnt proc srv tmp vmlinuz
boot etc initrd.img lost+found opt root sys usr vmlinuz.old
cdrom home initrd.img.old media output sbin test var

These are all files and directories found in the root (/) working directory (pwd). So now lets browse to /media:
root@m-ubuntu-vm:/# cd media/
root@m-ubuntu-vm:/media# ls
cdrom cdrom0 floppy floppy0

If you want to backup a directory you type cd .. which in this case would move you back out of /media to /.

If you want to get back home all you need to do is type cd ~:
root@m-ubuntu-vm:/media# cd ~
root@m-ubuntu-vm:~# pwd

Now that you are in your home directory type ls. You should see a few folders maybe Desktop and Documents. Now type again ls -a. Now you should see a bunch of files that begin with a period. This is because Linux/Unix/Mac is set to hide .file by default. If you browse a Unix file system on Windows or if a Unix machine browses a Windows file system Windows will see the .file. Most of these commands are capable of doing more than I am showing you. So another good command to know is the man command. Man stands for manual. Most commands have a manual so for ls if I type man ls it should return all of the options, syntax and documentation on that command. Try it out with these commands to get a feel for how a man page is laid out.

This gives you the extreme basics of browsing the Unix file system. There will be plenty more down the road, but if you are looking for immediate help I recommend ss64. This site lists a good portion of the default Unix/Linux/Mac commands available with their man pages and some good examples. Tuxfiles has a great tutorial as well as Linuxcommand.

The Linux CLI certainly has a higher learning curve than a simple gui, but I promise you that once you take the time to learn it you’ll find it far easier and more reliable.

Explore posts in the same categories: IT, Linux

One Comment on “Command Line Primer”

  1. […] protocol that allows remote accsess to Unix/Linux/Mac machines. If you know your way around the CLI in Linux than being able to access a machine remotely becomes very handy as you can do anything via […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: