Recent Articles

Using the Shell

Written by mike from http://beginlinux.com on April 26th, 2009 | 1 Comment

The Shell is the Linux equivalent of the CMD screen in Windows. Where it differs is that in Linux it is the heart of the system. It is rare that you use the CMD windows during normal operation in Windows, but once you are up to speed with Linux it will become second nature.

The Shell is also referred to as Bash (Bourne Again Shell) in Debian, but there are other versions of it around. The Shell is a command line interpreter, meaning it takes your command, turns it into Linux speak, processes the command, then produce the result.
To start the shell you can use the Terminal menu option from the GUI menu in Debian. You should then see a window much like the one above although it may be a different color.

shell

You will see one of two prompts. A $ which is the general user prompt, or a # for the root user. I would hope that especially during your first weeks with Linux you will be logging in as a general user and only using root when you need to.
The following are some basic commands to get you used to navigating the system. None of them will hurt anything, especially if you are in user mode. Note you don’t have to type the $.

$ pwd                  Will tell you what directory you are in.
$ cd                      Takes you to your home directory.
$ ls                        Lists the contents of your current directory
$ ls –l                   Displays the contents of the current directory in long format
$ ls –al                  Will show the long version of the directory including any hidden files
$ mkdir ‘name’     Will create a directory where ‘name’ is what you call it
$ rm ‘filename’     Deletes the file
$ rm –r ‘dirname’      Deletes the directory
$ cp file1 file2       Makes a copy of file1 and calls it file2
$ cp –r dir1 dir2     Makes a copy of directory1 and calls it dir2
$ mv file1 file2       This will move file one to file2
$ touch ‘filename’      Updates the file
$ more ‘filename’     Displays the contents of the file
$ head ‘filename’      Displays the first ten lines of the file
$ tail ‘filename’    Displays the last ten lines
Those are some of the basic file commands you can use to navigate and manipulate your files. How about a few command that give you information about your current machine and configuration?
$ date        Shows the current date
$ cal       Brings up the system calendar
$ uptime     Shows how long your system has been up. Useful for servers
$ df    Displays your disk usage
$ du   Displays your directory space usage
$ free   Displays your memory and swap file usage, again useful for servers
The shell is a massive subject, and one you should become familiar with over time. It is an extremely useful and powerful tool once you get the hang of it. Despite not being as pretty and as interactive as using the GUI, it seems to get things done quicker and in a no-nonsense kind of way.

Share/Save/Bookmark

 

You need to log in to vote

The blog owner requires users to be logged in to be able to vote for this post.

Alternatively, if you do not have an account yet you can create one here.

Powered by Vote It Up