Skip to content

Instantly share code, notes, and snippets.

@twei55
Last active April 15, 2024 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twei55/152d5d05c04944ebda2089eac57c1ea2 to your computer and use it in GitHub Desktop.
Save twei55/152d5d05c04944ebda2089eac57c1ea2 to your computer and use it in GitHub Desktop.
Linux Commands

Create tar.gz file with tar command

tar -czvf filename.tar.gz /path/to/folder

Untar tar.gz file

tar -zxvf filename.tar.gz /path/to/folder

Interactive Process Manager

$ htop

Monitor Nvidia GPUS

$ nvidia-smi

Number of files in directory

ls -1 | wc -l

Number of files in a directory and all subdirectories

find [folder-name]/ -type f | wc -l

Size of folder

du -sh [folder-name]/

Move first 100 files from one folder to another

mv `ls | head -100` ./destination_dir

Check if port is in use

netstat -an | grep PORTNUMBER | grep -i listen
(If the output is empty, the port is not in use)

Show all the firewall rules as defined on your system

iptables -L -n

Copy / move files based on modified date (Source)

find /path/to/folder -type f -mtime -1 -exec mv {} /path/to/new/dir \;

Find files that have timestamps after 2024-04-10 00:00 and before 2024-04-12 23:59

find -type f -newermt 2024-04-10T00:00 ! -newermt 2024-04-12T23:59

Show disk usage

sudo ncdu /path/to/folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment