Saturday, November 4, 2017

command line notes

get total number of processes
ps -ef | grep -v 'PID' | wc -l

get desktop resolution ------------------
xdpyinfo | grep 'dimensions:'

chmod ---------------------------
4 read (r)
2 write (w)
1 execute (x)


u stands for user.
g stands for group.
o stands for others.
a stands for all.
chmod u+x somefile     will grant only the owner of that file execution permissions
chmod +x somefile       is the same as chmod a+x somefile.
owner group all_users

Practical Examples
chmod 400 mydoc.txt read by owner
chmod 040 mydoc.txt read by group
chmod 004 mydoc.txt read by anybody (other)
chmod 200 mydoc.txt write by owner
chmod 020 mydoc.txt write by group
chmod 002 mydoc.txt write by anybody
chmod 100 mydoc.txt execute by owner
chmod 010 mydoc.txt execute by group
chmod 001 mydoc.txt execute by anybody

Wait! I don't get it... there aren't enough permissions to do what I want!

Good call. You need to add up the numbers to get other types of permissions...

So, try wrapping your head around this!!

7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)

chmod 666 mydoc.txt read/write by anybody! (the devil loves this one!)
chmod 755 mydoc.txt rwx for owner, rx for group and rx for the world
chmod 777 mydoc.txt read, write, execute for all! (may not be the best plan in the world...)

kill ---------------------------
kill -[signal or option] PID(s)
Signal Name Signal Value Behaviour
SIGHUP       1 Hangup
SIGKILL       9 Kill Signal
SIGTERM       15 Terminate

ldd ------------------------


nm -----------------------

No comments:

Post a Comment