Sometimes something happens that forces you to learn something new. Like when the Android emulator freezes on Fedora, and I can’t even close it! OK, keep calm, I remember something about Linux commands and how useful they are. Oh, really? Hmm, let’s take a closer look!
Obviously I was kidding! System commands are very useful to know, they can drastically improve the way your work.
Here are some that I find very useful.
Execute multiple commands in one line:
A; B # Run A and then B, regardless of success of A
A && B # Run B if and only if A succeeded
A || B # Run B if and only if A failed
A & # Run A in background.
Clear the terminal:
$ clear
Monitor processes. See tasks, memory, CPU and swap:
$ top
Monitor processes by user:
$ top -u username
While the command is running you have the following options:
Press ‘q‘ to quit window.
Press ‘z‘ to highlight everything.
Press ‘d‘ to set screen refresh interval.
There is an improved top command. It’s not installed by default on most Linux distributions, so you might have to install it first:
$ htop
And also by user:
$ htop -u username
Kill processes.
Signal the process to terminate gracefully:
$ kill PID
Find the PID (process identification number) of the process you want to kill with the top command or htop command.
If the process does not exit when asked nicely use:
$ kill -9 PID
Find PID of process running on particular port:
fuser 8080/tcp
Kill process running on a particular port:
fuser -k 8080/tcp
To be continued…