Posts Tagged ‘commands’

These are some of the basic Linux commands which can be used in the terminal . To open the terminal, press ALT+F2 and type gnome-terminal and hit ENTER. This will show you the terminal window where you can type in all your commands.

Shows the list of files in the current directory.

pwd is used to show which directory you are in at that time

cd directoryname”  will change current working directory to the inputed directory name.For example, if you want to change to directory “abc”, then you type: “cd abc

cd ..
Change the current directory to the previous directory.

cd ~
Go to the current user directory. For example, if your username is “root”, then it will go the user directory of root.

cat filename
This is used to display the contents of a file.
For example, you want to show the contents of a file named hello.txt , then you use the command “cat hello.txt

Prints the calender of the current month

This will print today’s date

su is used to switch user. You can use it by using the ” su username” .
For example, “su root” will switch current user to root. You will be prompted to enter the password, and after you enter the password you will be switched to user root.

mkdir directoryname
This is used to create a directory . For example : If you want to create a directory named abc, then type “mkdir abc

uname -a
This will print all your system related information like the operating system , kerenel version etc

uname -o
This will print the operating system that is currently in use.

This is used to copy a file to another location. For example you have a file name test1.txt and you want to copy it to /home/documents/ , then you have to type “cp test1.txt /home/documents

cp -R
This is used to copy directories. For example, to copy the folder /home/documents/dir1 to /home/root/ folder,  you use the command “cp -R /home/documents/dir1 /root/documents/

This is used to move a file or folder to another location. For example, if you want to move the folder /home/documents/dir1 to the location /root/, then you use the command “mv /home/documents/dir1 /root/

This command is used to the delete files or directories . For example, to delete the file hello.txt, you use the command “rm hello.txt

vi filename
This is used to create or open  a file in the vi editor. For example, if you want to create a file named “hey.txt” , you use the command “vi hey.txt” . To enter or insert text into the file, press i or INSERT button on your keyboard. After you have entered the text, to save the file and exit , press ESC and type :wq and hit ENTER on your keyboard. This will save your file and exit the editor and will go back to your terminal window.

touch filename
touch is used for creating text files. For example, to create  a text file name hello.txt, you type “touch hello.txt