If you are looking for Linux Commands from beginner to moderate & advance level, you have landed in the right place and website. This is not a complete and comprehensive list of commands. However, this can be helpful to kick-start of Linux commands and you might want to bookmark it for future reference. There are some commands which requires root (superuser) credentials and some are available for everyone. All the binaries are available on below location by default.
/sbin – However, to execute /sbin directory command need special permission or root credential.
/usr/bin – General system-wide binaries.
/usr/sbin -Binaries with superuser (root) privileges required.
In this series of tutorials, we will try to cover all Linux Commands which are useful in daily system operations.
Read Also: 10 – top command in Linux with examples.
Read Also: 11 – Essential Linux Commands For Network Configuration and Troubleshooting
Read Also: TAR Command in Linux
Read Also: sysstat – Linux System Performance Monitoring and Usage Tool
1. ls command examples:
ls is the very first command and frequently used command which list files and directory contents available on location.
Syntax:
ls [option] [file]
$ ls
ls without option shows directory contents on current directory.
Note:
$ ls -al
This will long list and shows hidden files also.
Also Read: Linux Commands That Every Linux System Administrator Should Know with Examples Part-2
Note: Type man ls [from Linux console] for more ls command options.
2. tar command examples:
Create a tar archive.
Syntax:
tar [option] [archive-file-name] [file-or-directory-to-archive]
# tar -cvf dir1.tar dir1/
Extract from existing tar archive, this will extract dir1.tar archive in /tmp directory.
# tar -xvf dir1.tar -C /tmp/
Note: Type man tar [from command prompt] for more tar command options.
Syntax:
pwd [OPTION]
Syntax:
cd [directory]
5. cat command example
One of the most frequently used command. cat is a short form of ‘concatenate’ and allow users to create file, list contents of a file, redirect file output etc.
Syntax:
cat [option][file]
$ cat > test.txt
$ cat test.txt
In the above screenshot we are creating test.txt file, awaits from user to input. “CTRL+D” to exit and contents will be saved on test.txt file. You may see the content of the file with cat command.
6. less command
less is useful command to displays large file contents in one page at a time in your terminal.
Syntax:
less [filename]
$ less test.txt
7. mkdir command
mkdir command helps user to create a directories. Creates directory called dir1 with below command.
Syntax:
mkdir [directory-name]
$ mkdir dir1
8. cp command example
cp command copy files and directories one place to other. While copying directory including it’s files and sub-directories use the -r option. Following command copy dir1 directory and it’s contents to destination testdir.
Syntax:
cp [option] [source][destination]
$ cp -r dir1/ tmpdir/
rm stands for remove is used to remove or delete files and directories.
Note: Cross check before removing any files and directories.
11. touch command example
touch command is used to create, change and modify timestamps of a file. This will create an empty file.
Syntax:
touch [filename]
# touch teclues.txt
# touch teclues1.txt teclues2.txt teclues3.txt
12. clear command
clear command is to clear terminal screen. This command is also available on Unix and other Unix-like operating system.
Syntax:
$ clear
13. df command example
df (disk free) command shows the disk free space in human readable format, filesystem types, and filesystem mounted on.
Syntax:
df [OPTION]… [FILE]…
$ df -h
-h (–human-readable)
14. du command example
du is short form of disk usage command shows disk usage by files and directories.
Syntax:
du [option] [file-name] [directory-name]
$ du -sh test.img
$ du -sh dir2
. -s option –summarize
. -h option –human-readable
15. find command example
find is also a one of the most frequently used command to search for a file and directory on your file system based on expression you specify.
Syntax:
find [option] [starting/path] [expression]
$ find . -name data.txt
16. grep command example
grep (stands for Global Regular Expression Print) command is used to search text or searches the given file for lines containing a match to the given strings or words.
grep [OPTIONS] PATTERN [FILE…]
$ grep teclues /etc/passwd
17. echo command example
echo command to display line of string/text in STDOUT that are being passed as an argument.
Syntax:
echo [option] [string]
$ echo “Hello teclues.com”
18. wc command example
wc stands for Word Count, As the name suggest is is used to count Newline Count, Word Count & Byte Count in the files specified in the arguments.
Syntax:
wc [option]…[file]…
$ ls -l | wc -l
Output
Above output shows number of lines along with ls -l command.
19. history command example
If you want to see the command executed in the past in Linux , history command shows the the commands that you have entered in the past.
Syntax:
history
$ history
20. w command example
w command shows information about users currently logged in and what they are doing currently on the system. Also shows the load average of the system.
Syntax:
w [options] [user]
$ w
21. who command example
who command shows information about users currently logged in on the system. Also shows the following information.
1. Date and Time of last system booted.
2. Number of users logged in
3. Current run level of the system
22. free command example
Output show in MB with option -m
Output shows that teclues user is switching to helen user, but he/she has to have password of user of which he/she switching over.
Also Read: Linux Commands That Every Linux System Administrator Should Know With Examples Part-4
25. date command example
26. timedatectl command example
28. locate command example
locate command to find the files by it’s name and search faster then find command. Becasue locate command search files in database instead of searching in filesystem. Database contains bits and parts of files and their related paths on system.
Syntax:
locate [option]… [pattern]…
$ locate test.img
While executing locate command, you may encountered error as “locate: can not stat () `/var/lib/mlocate/mlocate.db’: No such file or directory”. In this case, update locate database with updatedb command as shown above.
29. head command example
head command is a contrary to tail it shows beginning of a file. By default it prints first 10 lines of the file to standard output.
Syntax:
head [OPTION]… [FILE]…
Conclusion: In this first series of Linux commands, we have covered 30 Linux commands. We will be covering series of commands in the upcoming articles. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!