Photo by Alex Chumak on Unsplash
Linux Cheat Sheet every DevOps Novice must have
Linux Cheat Sheet you must have
What is Linux ?
Linux is the most important operating system in Networking World. Many Network Engineers, Network Administrators and Network Technicians use Linux in different areas of Computer Networking. They use different commands of Linux everyday. But sometimes, some commands can be forgotten. To overcome this issue, I have created a Linux Cheat Sheet for you! In this page, you will find Linux Cheat Sheet Commands.
Is Linux an Operating System?
Because of the fact that there are many versions, “is Linux a Opearing Sytem?” quesiton is very common. The answer is certainly Yes! Linux is an Open source Unix ilke Operating System. It is based on Linux Kernel. This Linux kernel was firstly released by Linus Torvalds at 17 September 1991. There are different distributions of Linux, some of these are:
- Red Hat
- Ubuntu
- Fedora
- Debian
- Suse etc.
All these Linux versions uses the same Linux commands and all the Basic Linux commands are similar in these Operating Systems. Linux find command, Linux delete command, Linux add user, Linuc copy file, Linux password change, Linux unzip etc. All these commands are similar in these versions. So, you can use Linux Cheat Sheet Commands on all these Linux distributions. In other words, you can benefit Linux command line cheat sheet on Red Hat, Ubuntu, Fedora, Debian, Suse etc.
I have realised that people often tend to forget that the Linux is not about the GUI its all about how much you can operate via the Terminal. So what I have tried here is tried to inculcate all the commands in some group in the form of list.
For the basic linux commands. You can have a look at these articles; In which I have included most of the basic commands.
Part 1 - Fundamental Linux Commands
Part 2 - Fundamental Linux Commands
Types of Commands are as follows:
File Commands
ls -l lists files detailly (file type, user, permission etc)
ls -lh lists files detailly with human readable format
ls -al lists files detailly with hidden files
pwd shows present directory
mkdir directory creates a directory
rm xyz deletes file xyz
rm -r /xyz deletes directory /xyz and its contents recursively
rm -f abc forcefully deletes abc file without confirmation
rm -rf /xyz forcefully deletes directory /xyz recursively
cp aaa bbb copies aaa file to bbb file
cp -r /xxx /yyy copies /xxx directıry to /yyy directory
mv aaa bbb renames or moves file aaa to file bbb
touch abc creates an empty file named abc
cat abc used to view file abc
less abc browse through a text file abc
head abc displays first 10 lines of file abc
tail abc displays last 10 lines of file abc
tail -f abc displays last 10 lines of file abc and follow it as it grows
tail -F abc outputs last lines of abc as it changes
file abc gets type of abc
gpg -c abc encrypts file abc
gpg abc decrypts file abc
gpg abc decrypts file abc
gpg abc decrypts file abc
dir shows files in the current directory
put abc uploads file ‘abc’ from local to remote device
get file downloads file ‘abc’ from remote to local device
ls options which are included
-a display hidden files
-R recursive List gets visible
-r reverse order gets visible
-t sort by last modified
-m comma-separated output
Install Commands
Considering we are operating on Red Hat Enterprise Linux
yum search keyword compresses abc file using gzip.
yum install abc installs abc package
yum info abc displays description and summary info about abc package
rpm -i abc.rpm installs package from local file named abc.rpm
yum remove abc Remove/uninstall abc package
yum list installedl lists all installed packages with yum
yum search [keyword] finds a package by a related keyword
yum info [package_name] shows package information and summary
yum install [package_name.rpm] installs a package using the YUM package manager
dnf install [package_name.rpm] installs a package using the DNF package manager
apt-get install [package_name] installs a package using the APT package manager
rpm -i [package_name.rpm] installs an .rpm package from a local file
rpm -e [package_name.rpm] removes an .rpm package
Disk Usage Commands
df shows file system disk usage
du shows disk usage for specific directories
du -a shows disk usage for all the files
du -s shows used total disk space
free shows free and used memory on the system
fdisk used to manipulate disk partition table
fdisk -l used to list disc partition table
sfdisk used to manipulate disk partition table with more features
cfdisk linux partition editor with an interactive user interface
findmnt lists all mounted file systems
mount mounts a filesystem
parted lists and modifies partitions
parted -l lists the partition details
lsblk lists all the storage blocks including partitions
blkid prints the block device partitions and storage media
File Permissions
chown user changes ownership of a file/directory
chown user:group filename changes user and group for a file or directory
File Permissions
r (read) permission, 4
w (write) permission, 2
x (execute) permission, 1
-= no permission
File Owner owner/group/everyone
File Permissions Examples 777 | Owner, Group, Everyone has rwx permissions
744 | Owner has rwx permission, Group, Everyone has r permission
755 | Owner has rwx permission, Group, Everyone has rx permissions
776 | Owner, Group has rwx permission, Everyone has rw permissions
User Information Commands
id shows user&group ids of the current user
last shows the last users logged on
whoami shows who you are logged in as
who shows who is logged into the system
w shows who is logged in and what they do
groupadd test creates group “test”
useradd -c “GK” -m Gokhan creates “Gokhan” account with comment “GK”
userdel Gokhan deletes account “Gokhan”
usermod -aG Networkers Gokhan adds account “Gokhan” to the “Networkers” group
System Information Commands
uname -a shows Linux system info
uname -r shows kernel release info
cat /etc/redhat-release shows installed redhat version
uptime displays system running/life time
hostname shows system host name
hostname -I shows ip addresses of the host
last reboot displays system reboot history
date displays current date and time
cal displays monthly calendar
mount shows mounted filesystems
Help Commands
command -h / command –help to review all available options of the “command”
info command to find info documents about the “command”
whatis command displays a single line description about the”command”
$ man UNIXCOMMAND to view detailed man page of the “command”
apropos used to search man pages for available commands on a specific functionality.
I hope this gives you a gist regarding the Linux Commands and helps to become a Linux Master. Eventual practice of commands helps you to retain the knowledge of commands used so please feel free to use the commands rather than interacting with the GUI. It will definitely help you to make you a good hold of Linux Commands.