Linux
| Created | |
|---|---|
| Language | |
| Last Edit |
Cheat Sheet
Common Commands
Find
1. find . -name thisfile.txt
If you need to know how to find a file in Linux called thisfile.txt, it will look for it in current and sub-directories.
2. find /home -name *.jpg
Look for all .jpg files in the /home and directories below it.
3. find . -type f -empty
Look for an empty file inside the current directory.
4. find /home -user randomperson-mtime 6 -iname ".db"
Look for all .db files (ignoring text case) that have been changed in the preceding 6 days by a user called randomperson.
Hide User & Directory Prompt Details
export PS1="\$ "Port Owner
lsof -i :8000Tail
Command displays the last 100 lines of the log.
tail -n 100 some_log.logBasics
OS Details
Get Release Version
lsb_release -aSystem Hostname
hostnamectlRelease File Content
cat /etc/*releaseDisk Info
Filesystem disk space usage
df -hInformation about block devices, including disks and partitions
lsblkServices
List all services
systemctl list-units --type=serviceList running services
systemctl list-units --type=service --state=runningList enabled (set to start on boot) services
systemctl list-unit-files --type=service --state=enabledStatus of specific services
systemctl status <service-name>User Management
Add User
sudo adduser <username>Add User To sudo Group
To give the new user administrative privileges (allowing them to use sudo)
sudo usermod -aG sudo <username>Switch User
su - <username>