Command Line Tips

Photo by me

Bash Command Line Tips to Help You Work Faster
Refer to: https://www.freecodecamp.org/news/bash-command-line-tips-to-help-you-work-faster

  • Continue add items to this article to help me record some useful commands

1. Use Control + L to clear the screen and Control + D to exit

2. Use the nohup command to spawn processes that don’t end with the terminal session

1
nohup firefox https://freecodecamp.org &

3. Use pkill to kill processes by typing in only a part of the name

1
2
3
killall firefox

pkill fire*

4. Prepend the time command to know how fast something executes

1
time python3 concalate_nonce.py

5. Know the public IP address of your computer using curl

1
2
3
curl ifconfig.me ; echo

curl ifconfig.co ; echo
1
2
3
crtl + r

(reverse-i-search)`watch': watch -n 0.1 nvidia-smi

7. show file count by directory

1
2
3
find . -type f | sed 's%/[^/]*$%%' | sort | uniq -c

du -a | cut -d/ -f2 | sort | uniq -c | sort -nr

8. Show folder size

1
2
3
4
5
#Show specify folder
du -h /path/to/directory

# Show all folders
du -h | sort -h

9. Find matched line from csv file

1
grep ,1 abc.csv

10. Find filename in csv file and mv to new folder

1
grep ,1 abc.csv | cut -d "," -f1 | xargs -I {} mv {} new_folder