Linux commands cheat sheet

In this tutorial, we will learn some basic linux commands or popularly know as linux commands cheat sheet which are useful for Beginners.You can also refer Linux commands cheat sheet of this series. Linux is a family of of open-source Unix-like operating systems based on the Linux kernel. Linux is an operating system kernel created and developed by Linus Torvalds. Linux being open source, it can be modified and used freely.Linux is mostly used in servers as its free, fast and secure and consumes less resources as compared to windows servers. Linux servers uses shell or terminal for processing user data or commands. Internet is majorly powered by Linux servers as its virus free and secure.

There are many flavours of Linux which are popularly know as Linux Distributions. Some of the most popular distributions are

  • Debian
  • Fedora linux
  • Ubuntu
  • CentOS

Commercial distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise.

Getting started: Linux commands cheat sheet

1. cat

The cat  (catenates) command is a utility command in Linux. One of its most commonly known usages of cat command is to print the content of a file onto the standard output

[ved@arch ~]$ cat ved.txt 
hello
world

cat ved.txt raj.txt

This cat command will display the content of both the files ved.txt and raj.txt on the standard output

[ved@arch ~]$ cat ved.txt raj.txt 
hello
world
welcome to
makeuseoflinux.com

cat ved.txt raj.txt > 123.txt

This command will catenates the content of both the files ved.txt and raj.txt and create a new file called 123.txt. We can see both the files content in 123.txt

[ved@arch ~]$ cat ved.txt raj.txt > 123.txt

2. mkdir

Mkdir command is used to create directory (also referred as folder) in linux. This command can be used to create multiple directories in single command if the user creating the directories have required permissions where the directory is being created.

[ved@arch ~]$ mkdir test

We can also create directories which are missing in between directories for example we have /opt/applications and we want to create /opt/dev/applications/app1

[ved@arch ~]$ mkdir -p /opt/dev/applications/app1

3. cp

Cp command is used to copy files and directories in linux. By default, ‘cp’ does NOT preserve the original modification time of the files

[ved@arch ~]$ cp ved.txt test/

We can use cp -v to display the cp command verbosely

[ved@arch ~]$ cp -v raj.txt test/
'raj.txt' -> 'test/raj.txt'

4. mv

Mv command is used to move files and directories from one directory to other directory. It can also be use to rename the file or directory.

[ved@arch ~]$ mv raj.txt test/

Renaming raj.txt to new.txt

[ved@arch test]$ mv raj.txt new.txt

5. rm

rm command is used to remove or delete files or directories. When rm command is used without any parameters, it prompts before deleting files or folder. When used with -f option, it will delete files without prompting before deletion.

[ved@arch test]$ rm new.txt 

6. touch

touch command is used create a new file or it is used to update the timestamp of a file

This will create a file of zero byte size if it doesn’t exist

[ved@arch test]$ touch test.txt

7. stat

The stat command will display statistics of the file. Stat command gives information such as the size of the file, access permissions and the user ID and group ID, birth time access time of the file

[ved@arch test]$ stat test.txt 
  File: test.txt
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 0,39	Inode: 737212      Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ved)   Gid: ( 1000/     ved)
Access: 2022-03-29 18:01:58.247492573 +0530
Modify: 2022-03-29 18:01:58.247492573 +0530
Change: 2022-03-29 18:01:58.247492573 +0530
 Birth: 2022-03-29 18:01:17.648352828 +0530

8. find

find command is used to search files based on pattern in linux. Below command will search for “fstab” pattern under the root file system

[ved@arch test]$ find / -name 'fstab'

9. alias

alias command is used to set alias or display the current aliases.

[ved@arch test]$ alias 
alias ls='ls --color=auto'

[ved@arch test]$ alias copy='cp -v'

10. hostname

hostname command is used to display or print the hostname of the system

[ved@arch ~]$ hostname
arch

Conclusion

We have explored various linux commands which we can practice to make our self familiar for day to day use. This linux commands cheat sheet can be kept handy for quick reference.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments