Monday 25 July 2011

Some Basic Linux Commands


In this post I want to discuss about some basic Linux Commands. I think this post will useful for all beginners who are interested in Linux. 
Linux terminal is one of the very good command line interfaces out there. Knowing Linux commands  may help you better understand your system and increase your efficiency. Opening your terminal in Ubuntu is very easy. Just go to..
 
Applications->Accessories->Terminal.

The prompt of the terminal shows something like this:

anoop@anoop-laptop:~$

The first name is your username and the one after the @ is your hostname.
After the colon ~ represents your home folder(you always start at your home folder by default)
$ is the prompt symbol in linux just like > in windows ( C:\> )

A Linux command normally consists of three parts: the command itself, the command options, and its arguments. For instance, the following example shows what a linux command looks like.

useradd -m -G sales India

This example consists of three parts, useradd, which is the command; -m and -G sales, which are both options; and India, which is a generic argument.

There are many Linux commands are there, Here I want to discuss only about some basic commands that we are frequently used.

cd command: Just like in Windows changes the diretory(case sensitive). But 
                     cd.. or cd. doesn't work here.
                     Usage: username@computer:~$ cd Documents
                     You can use a directory in place of Documents.

ls command: This command lists the files in your current folder. use ls -al to
                    display all files(includes hidden) and their details.
                    Usage : username@computer:~$ ls -al

mkdir command: Allows you to create directories.
                          Usage: username@computer:~$ mkdir myvideo

man command: opens a help file for a command. Press Q to exit.
                        Usage: username@computer:~$ man ls

cat command: To view the contents of a file in current directory.
                      Usage: username@computer:~$ cat text1.txt

rm command: Deletes/Removes a file from the directory().
                      Usage: username@computer:~$ rm text1.txt 

cp command: Makes a copy of the file. The original file remains there.
                     Usage: username@computer:~$ cp text1.txt copyoftext1.txt
pwd command: This command prints the current working directory.
                        Usage: username@computer:~$ pwd

mv command: Moves the file form one directory to another.The original file is 
                      moved.
                      Usage: username@computer:~$ mv /home/Desktop/text1.txt /home
cal command: Displaying a calender.
                      Usage: username@computer:~$ cal

clear command: Clear your screen so that you can see in a better way what you are doing.
                      Usage: username@computer:~$ clear

uname command : Displaying system information with uname and  hostname. 
Uname command with no arguments will  just   show   the kind of  kernal  you are using.
                        uname -r display the kernal version.
                        uname -p display the type of CPU.
                        uname -a display all the details of your Computer.
                        Usage: username@computer:~$ uname -a

wc command: wc means word count. Used to know how many words there are in a file.
                         Usage: username@computer:~$ wc filename
date command: Display the current date and time.
                         Usage: username@computer:~$ date

These are some basic commands we are frequently used in Linux command prompt. I will show you some other commands in the next post.

No comments:

Post a Comment