In Linux system all basic and advanced tasks could be done by using commands. Linux commands help you to interact with the system. We have to run the commands on terminal, in Window OS it is called as command prompt. By using terminal, we can interact with the Linux system.
1. ls – list
This command is used to display or used to list the contents of a directory.
2. ls -ltr
This command is used to list the files according to which time they were created.
Here, l-long listing, t-time, r-reverse order.
3. pwd – present working directory
It will show you the present working directory.
4. cd – change directory
It is used to change the directory.
Syntax:
cd <directory_name>
e.g.,
cd Desktop
5. mkdir – make directory
By using this command, we can create a directory.
Syntax:
mkdir <directory_name>
e.g.,
mkdir user
6. rmdir – remove directory
This command is used to remove or delete empty directory. But if the
directory we are going to delete contains files or subdirectories, such directory can’t
be removed by this command.
Syntax:
rmdir <directory_name>
e.g.,
rmdir user
This will delete the directory ‘user’ if it is empty otherwise it will give an error.
7. rm – remove
This command removes files, directories.
Syntax:
rm <directory_name>
e.g.,
removing one file –
rm file1.txt
removing more than one files at a same time
rm file1.txt file2.txt
8. cp- copy
This command is used to copy one file into another file or copy a file to specified path
Syntax:
cp <source_file_name> <destination_file_name>
cp <file_name> <path, where you want to copy this file>
e.g.,
cp a.txt b.txt
cp a.txt /Desktop
9. mv – move
This command is used to move directory or a file from one location to
another.
Syntax:
mv <file_name> <directory_path>
e.g.,
mv a.txt Directory
10. tail –
This command is used to display the last 10 lines of a file.
Syntax:
tail <file_name>
11. su – super user
This command is used to provide the administrative access to the other user. When you enter this command, it will ask you for a password at that time you have to provide the password for that user.
Syntax:
su <user_name>
12. sudo -super user do
this command especially used as a prefix with some other commands to run
with some extra privileges. The working of this command is same as ‘Run as
Administrator’ option in Windows.
Syntax:
sudo command
13. clear-
This command clears the terminal screen.
Syntax:
Clear
14. exit –
This command is used to exit from the currently working shell.
Syntax:
exit
15. wc – word count
This command is used to count the characters, words, lines in a
specified file.
Syntax:
wc <file_name>