Shih-Min Lee's Personal website

dating, chating, food, games, search

Follow me on GitHub

Some linux commands that I use often

Abstract

When you deploy your service on the cloud you frequently need to ssh in the instance and check something on the server. Most likely you will have to check some logs, monitor cpu and memory usages.

Thing I do often

$ free -m

Check the available memory on your machine

$ ps aux --sort -rss | head

Display processes with top 10 memory usage (not working on a Mac)

$ df -h

check the avilable disk space

$ last

check last ssh-in user

$ tail xxx.txt -n 20

read the last 20 lines of xxx.txt, you can also ignore the -n part

$ whoami

this tell you who you are.

$ ll

check file permissions. detailed explaination can check this link http://mason.gmu.edu/~montecin/UNIXpermiss.htm

$ sudo -u username xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

you can run processes using different username

$ lsof -t -i :8000 | xargs ps -fp

checking what program is listening port 8000

tail -f /proc/1234/fd/1

Check the outputs of a running process with pid 1234 (not working on a mac)

⌘ + D

Split the window

Shift + ⌘ + D

Undo split the window

ls -l 

Check file and folder owners.

ll

Check file and folder owners, even the hidden files.

utilities that I use

  • ncdu (use this to check disk space and usage)

  • screen (use this to open multiple screens and run processes in them)

references:

16 Nov 2015