You can do a lot using just commands on Linux. Through the Terminal, you can type the command that you want and perfume many actions and diagnostics. Depending on the distro you are using, you will have a different shell pre-installed (bash, dash, etc.). They can have small differences, but for the majority of command, they will work the same.
You can also change the shell if you like. Here you can see a Linux commands cheat sheet with the main commands and what they do.
MTR command – Everything you need to know
SYSTEM | HARDWARE | ||
uname | Information about the system | dmesg | Show bootup messages |
uname -r | Information about the kernel release | cat /proc/cpuinfo | CPU information |
hostname | System’s hostname | cat /proc/meminfo | Memory information |
hostname –i | The IP of the system’s host | lshw | List the hardware components |
last reboot | System reboot history | lsbkl | List block devices |
date | Current system’s time and date | free –m | Shows free memory |
timedatectl | Change system’s clock | lsspci –tv | Shows list of PCI devices |
cal | Calendar, month and day | lsusb –tv | Shows list of USB devices |
w | Shows which user is currently logged | dmidecode | Shows hardware information from the BIOS |
whoami | User’s information | hdparm -i /dev/xda | Shows information about disk data |
finger username | Show information for a particular user | hdparm -tt /dev/xda <:code> | Performs read speed test (disk) |
USERS | badblocks -s /dev/xda | Checks for bad blocks on disk | |
id | Shows information about the current user | FILES | |
last | Shows last login | ls –al | List of all files including hidden |
who | Shows who is logged in | pwd | Shows the current directory’s path |
groupadd “admin” | Adds “admin” group | mkdir ‘new’ | Makes new directory called “New” |
adduser “michael” | Adds “Michael” as a user | rm file_name | Removes the file you wrote |
userdel “michael” | Deletes “Michael” from users | rm -f filename | Removes the file you wrote with force |
usermod | Changes user’s information | rm -r directory_name | Removes the directory you wrote recursively |
PROCESS | rm -rf directory_name | Removes the directory you wrote recursively and forcefully | |
ps | Shows active processes | cp filea fileb | Copies the content of filea to fileb |
ps aux | grep ‘telnet’ | Seaches the “telnet” process’ id number | cp -r dira dirb | Copies dira to dirb recursively. Creates dirb if doesn’t exist |
pmap | Shows processes’ memory map | mv filea fileb | Moves, renames filea to fileb |
top | Shows all running processes | ln -s /path/to/file_name link_name | Symbolic link to file_name |
kil pid | Kills process with a given pid | touch file_name | Creates a new file (file_name) |
killall proc | Kills all processes named proc | cat > file_name | Puts standard input into a file |
pkill process-name | Sends a signal to a process with its name | more file_name | Outputs file’s content |
bg | Resumes background processes | head file_name | Shows the first 10 lines of the file |
fg | Foreground for the suspended jobs | tail file_name | Shows the last 10 lines of the file |
fg name | Foreground for the job “name” | gpg -c file_name | Encrypts a file |
lsoft | List of files that processes have opened | gpg file_name.gpg | Decrypts a file |
renice 19 pid | Runs the pid with low priority “19” | wc | Prints bytes, words ,and line into a file |
pgrep name | Find “name” process ID | xargs | Executes commands from standard input |
pstree | Shows processes in a tree model | INSTALL SOURCE (COMPILATION) | |
INSTALL PACKAGES | ./configure | Checks the system for the required software for building the program. Creates a Makefile container. | |
rpm -i pkg_name.rpm | Installs a rpm package | make | Reads the Makefile to compile the program. |
NETWORK | make install | Installs the binaries after the compilation. | |
ip addr show | Shows IP addresses and all network interfaces | LOGIN | |
192.168.0.1/24 dev eth0 | Assigns 192.168.0.1 (IP address) to eth0 (interface) | ssh user@host | Securely connect to host as user |
ping host | Ping a host and see the connection | ssh -p port_number user@host | Securely connect to host using a specified port |
whois domain | Shows information about the domain | ssh host | Securely connect to the system via SSH default port 22 |
dig domain | DNS information about the domain | telnet host | Connect to host via telnet default port 23 |
host domain | DNS information about the domain | DISK USAGE | |
netstat -pnltu | Shows all active listening ports | df -h | Shows free space on the mounted system |
DIRECTORY TRAVERSE | df -i | Shows free space inodes on file system | |
cd .. | Up one level in the directory | fdisk -l | Shows disk partitions, sizes, and types |
cd | Changes directory to the Home directory | du -sh | Shows disk usage in the current directory |
cd /test | Changes directory to /test | findmnt | Displays target mount point for all filesystems |
mount device-path mount-poin | Mount a device | ||
You can print this Linux commands cheat sheet and use it as much as you like in your job. It could save you time and make you more productive.