File/Directory Management
touchlslncpmkdirmvrmrmdirwhichreadlink
Viewing/Searching Files:
cattail -flessmorewatchdiffgrepfindwc-llsof
Permissions/User Account
chmodchownuseradd,userdelpasswd/etc/passwd,/etc/shadow,/etc/group/etc/gshadow
Remote File Transfer
sshscpftp/sftprsyncwgetcurl
File System Commands
lsblkfdiskdudffsckmkfsmount,umount
String Manipulation
sedawktr
Git
gitinitpullpushfetchcommitbranchcheckoutmergecherry-picklogstatusaddrmdiff...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 --decoratefor a colorful visual git log.
Networking
digtracerouteip rip aip link...pingnetcatncnslookuptcpdumpiptablesufwfirewalld
System and Processes
servicesystemctlpscommonly used with-auxor justauxtop
Misc. Commands
- Search for an installed package/library:
ldconfig -p | grep <package/library>orwhereis <package/library> mdadmfor managing linux software RAID.sortuniqmost commonlyuniq -ctar -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.lspcilscpudmidecodelshal- Get lots of hardware information (including some dmi info) without needing root access.uname -rPrint 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.socatvisudo- Edit the /etc/sudoers file.modprobe- Add or remove modules from the Linux kernel.dkms- Rebuild dynamic kernel modules.ipmitoolUsed to query ipmi data and controlling ipmi devices.ipmitool sdrdumps sensor data.teetartar -cvf archivename.tar /path/to/directory- Create an.tararchive of a directory.tar -xvf archivename.tar- Extract (unpack) the.tararchive.- Add the
-zflag 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+Ragain to view more matches.--two dashes signifies the end of command options, and allows you to specify "-" options as regular arguments.- e.g.
cat -- -zwould print out the contents of a file named "-z" whilecat -zwould print an error.
- e.g.
&Add an ampersand after a command to make it run in the background.