Show Menu
Cheatography

Linux Cheat Sheet <CentOS/Fedora based> Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Built-in manuals and info

man <Command>
Show manual for the command
info <Command>
Show wide info about the command (Can be secondary to man)
<Command> --help
Short comman­d/tool usage

System info

uname -a
Show system and kernel version
history
Show current user bash commands history
date
Show current date and time
cal
Show calendar
uptime
Show system uptime
df -h
Show all mounted file systems
du -h <Path>
Show disk usage, to get better unders­tanding what is taking all the disk space
free -h
Show available memory and usage
which <Command>
Show the binary­/script location if it is under the $PATH
top
Show running processes on realtime
ps -aux
Capture all running processes and print in terminal
dmesg
Print or control the kernel ring buffer
cat /var/log/syslog
Show system logs
journalctl
Query the systemd journal

Bash Variables

env
Show enviro­­nment variables
echo $HOME
Home directory
echo $PATH
Executable search path
echo $SHELL
Current shell

Navigation

cd <Path>
Change directory
pwd
Present/print working directory
ls
List directory contents
ls -la
Long list directory contents
and hidden files and wide info
find /home/user -name '*.txt'
Search and print
all the .txt files
under the user directory
mount
show or mount filesy­stems
umount
unmount file systems

File manipu­lation

touch
Update the file last modifi­cation date, if the file does not exist, touch will create a new file
cp
Copy files
mv
Move files, also used to rename a file
rm
Delete files or direct­ories ( can be used with -r for recursive)
mkdir
Create new directory
rmdir
Delete directory (Only if empty)
chmod
Change file mode/p­erm­issions r=4 w=2 x=1
chown <owner:group>
Change file ownership
cat
Print file content
head
Show first 10 lines of a file
tail
Show last 10 lines of a file
tail -F
Output last lines of the file as it changes
file
Show info about the file such as file type
 

Users and groups management

whoami
Show current user
sudo adduser <Username>
Create a new user
sudo userdel -rf <Username>
Delete user ( Including the home directory )
sudo passwd <Username>
Change user password
id
Show user uid, groups and info
who
Show current logged in users
sudo usermod -aG <Group> <User>
Add user to group
sudo groupdel <Group>
Delete group
cat /etc/group
List all groups
cat /etc/passwd
List all users

Disk utils

 

IO Redire­­ction

cmd < file
Input to cmd from file
cmd1 <(cmd2)
Output of cmd2 as file input to cmd1
cmd > file
stdout of cmd to file
cmd > /dev/null
Discard stdout of cmd
cmd >> file
Append stdout to file
cmd 2> file
stderr of cmd to file
cmd 1>&2
stdout to same place as stderr
cmd 2>&1
stderr to same place as stdout
cmd &> file
Every output of cmd to file
cmd = Command
stdout = Standard output
stderr = Error output

Package management

dnf upgrade
Upgrade a package or packages on your system
dnf search <Package>
Search package details for the given string
dnf remove <Package>
Remove a package or packages from your system
dnf repolist
Display the configured software reposi­tories
rpm -i <Package>
Install rpm package
rpm -e <Package>
Uninstall rpm package

Networking

ifconfig -a
Show all network interfaces and more
netstat
Print network connec­tions, routing tables, interface statis­tics, masquerade connec­tions, and multi-cast member­ships

VIM Editor

 
Delete character

VIM Editor

:x + enter
Save and quit
:q! + enter
exit, discard changes
x
Delete character
i
Insert text
a
append text
dw
Delete word
d$
Delete to the end of the line
0 (Zero)
Move to the start of the line
2w
Jump 2 words
d2w
Delete 2 words
dd
Delete a whole line
2dd
Delete 2 whole lines
u
Undo previous actions
U
Undo all the changes on a line
CTRL-R
Undo the undo's
r
Replace character