File/Directory Management
touch
ls
ln
cp
mkdir
mv
rm
rmdir
which
readlink
Viewing/Searching Files:
cat
tail -f
less
more
watch
diff
grep
find
wc
-l
lsof
Permissions/User Account
chmod
chown
useradd
,userdel
passwd
/etc/passwd
,/etc/shadow
,/etc/group
/etc/gshadow
Remote File Transfer
ssh
scp
ftp
/sftp
rsync
wget
curl
File System Commands
lsblk
fdisk
du
df
fsck
mkfs
mount
,umount
String Manipulation
sed
awk
tr
Git
git
init
pull
push
fetch
commit
branch
checkout
merge
cherry-pick
log
status
add
rm
diff
...git diff <COMMIT HASH>^ <COMMIT HASH>
allows you to view the changes of a specific git commit. Can also usegit show <COMMIT HASH>
.git log --graph --decorate
for a colorful visual git log.
Networking
dig
traceroute
ip r
ip a
ip link
...ping
netcat
nc
nslookup
tcpdump
iptables
ufw
firewalld
System and Processes
service
systemctl
ps
commonly used with-aux
or justaux
top
Misc. Commands
- Search for an installed package/library:
ldconfig -p | grep <package/library>
orwhereis <package/library>
mdadm
for managing linux software RAID.sort
uniq
most commonlyuniq -c
tar -xzvf <name-of-archive.tar.gz>
extract a .tar.gz archive.tar -czvf <name-of-archive.tar.gz> </path/to/directory-or-file>
create a .tar.gz archive.lspci
lscpu
dmidecode
lshal
- Get lots of hardware information (including some dmi info) without needing root access.uname -r
Print the Kernel Release. Can also docat /etc/*release*
to check Linux distro/version.xargs
-I%
-P <Threads>
-n <Max Args>
Allows you to run multiple commands in parallel.socat
visudo
- Edit the /etc/sudoers file.modprobe
- Add or remove modules from the Linux kernel.dkms
- Rebuild dynamic kernel modules.ipmitool
Used to query ipmi data and controlling ipmi devices.ipmitool sdr
dumps sensor data.tee
tar
tar -cvf archivename.tar /path/to/directory
- Create an.tar
archive of a directory.tar -xvf archivename.tar
- Extract (unpack) the.tar
archive.- Add the
-z
flag to both commands to compress (gzip) the archive.
Useful (Bash) Tricks
- Use
|
to pipe the results from one command into another (e.g.cat names.txt | sort
)- This is paramount to the "Unix Philiosphy"
- Stream redirection
<
- Overwrite standard input<<
- Append standard input>
- Overwrite standard output>>
- Append standard output
history
- View bash history.- You can then type
!<number>
to enter that command from your bash history.
- You can then type
Ctrl
+R
- Search through bash history. Begin typing a search query, and can pressCtrl
+R
again to view more matches.--
two dashes signifies the end of command options, and allows you to specify "-" options as regular arguments.- e.g.
cat -- -z
would print out the contents of a file named "-z" whilecat -z
would print an error.
- e.g.
&
Add an ampersand after a command to make it run in the background.