Skip to content

Instantly share code, notes, and snippets.

@manninofrancesco
Last active April 29, 2024 13:39
Show Gist options
  • Save manninofrancesco/0757a674acceda80a58efc78a422db59 to your computer and use it in GitHub Desktop.
Save manninofrancesco/0757a674acceda80a58efc78a422db59 to your computer and use it in GitHub Desktop.
Linux commands
# Permission of file or folder
ls -l
#Example output: drwxr-xr-x 2 root root 4096 Jan 19 08:45 database_backups/
#1. Type: - for file and d for directories
#2. Permissions: rwxr is for root user | xr is for root group users | x is for others
#3. User Owner: root
#4. Group Owner: root
#Docs: https://www.redhat.com/sysadmin/linux-file-permissions-explained
# Find things
find "/path" -name "*.extension"
# Params: https://www.computerhope.com/unix/ufind.htm
# Check disk usage
df
# Check file size (you can avoid filename and it will list all files with their size)
ls -lh filename
# Read last n rows of a file
tail -n 50 -f /path/to/your/logfile
# Search for a string
sudo find / -type f -exec grep -H 'your_search_string' {} +
#Copy all files, included hidden ones from a folder to another
#Attention: check if shopt -s / -u dotglob is required
cp -r /source/folder/* /destination/folder
# Check process and their port on Mac OS
lsof -i tcp:3013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment