Linux Basics#
Filesystem#
- pretty print stats about file
Bash
stat [file]
- delete directory
Bash
rm -rf
- find file/directory recursively
Bash
find . -name _gsdata_ -exec rm {} +
find . -type d -name _gsdata_ -print -exec rm -rfv {} +
find . -type f -name \( -name .DS_Store -o -name Thumbs.db \) -print -exec rm {} +
chmod
: change permissions to folders and files
Bash
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +
chown
: change ownership to user/group recursively
Bash
chown -R user:group /some/path/here
chmod
recursively to 775/664
Bash
chmod -R a=,a+rX,u+w,g+w /some/path/here
^ ^ ^ ^ adds write to group
| | | adds write to user
| | adds read to all and execute to all folders (which controls access)
| sets all to `000`
Processes/Services#
id
: find UID/GID for user
Bash
id [username]
- list running processes
Bash
ps aux
- start/stop/restart the specified service
Bash
systemctl start [service]
systemctl stop [service]
systemctl restart [service]
- enable/disable service to auto start at boot time
Bash
systemctl enable [service]
systemctl disable [service]
- show/check service current status/runtime information
Bash
systemctl status [service]
systemctl is-active [service]
systemctl is-enabled [service]
systemctl is-failed [service]
systemctl list-dependencies [service]
- list running services
Bash
systemctl | grep running # Loaded+Active
systemctl --no-pager | grep running | column -t # For more readable output
systemctl list-units --all # Loaded services
systemctl list-units --all --state=inactive # Inactive services
systemctl list-units --type=service
systemctl list-units --type=service --state=running
systemctl list-unit-files # All installed i.e. Loaded+Unloaded
Last update:
2023-03-10