Posted: . At: 10:57 PM. This was 11 years ago. Post ID: 5998
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Misc UNIX and Linux tricks for the desktop user and administrator.

TRON Legacy UNIX login to an sh prompt.
TRON Legacy UNIX login to an sh prompt.

Uptime. this is a useful command for finding out how long a Linux system has been running for. it also displays the load average over 1.5 and 15 minute intervals.

deep-thought ~ # uptime
21:45:32 up 32 min, 3 users, load average: 1.88, 1.45, 1.08

The w command will show the users that are logged into your Linux system and where they are logged in.

deep-thought ~ # w
22:04:39 up 51 min, 2 users, load average: 0.82, 0.76, 0.88
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
homer tty7 :0 21:14 51:08 22:12 0.07s gdm-session-worker [pam/gdm-password]
homer pts/0 :0.0 22:03 7.00s 0.28s 0.34s mate-terminal

To stop a service on a Linux system use the service command. This is used to stop and start services easily.

deep-thought ~ # service apache2 stop
* Stopping web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting

And this is how to start the service on Linux.

deep-thought ~ # service apache2 start
* Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

The free command is used to show how much free memory there is on your system. A very useful command indeed.

deep-thought ~ # free
total used free shared buffers cached
Mem: 6043416 4419804 1623612 0 862984 2024672
-/+ buffers/cache: 1532148 4511268
Swap: 15885300 0 15885300

This is the command the systems administrator used in the movie TRON Legacy. Here I am looking for a certain process ID. This also shows the processes running under the mate-terminal process.

deep-thought ~ # ps -ef | grep 7378
homer 7378 3406 0 22:03 ? 00:00:01 mate-terminal
homer 7384 7378 0 22:03 ? 00:00:00 gnome-pty-helper
homer 7385 7378 0 22:03 pts/0 00:00:00 zsh
root 7742 7505 0 22:29 pts/0 00:00:00 grep --colour=auto 7378
TRON Legacy Encom UNIX machine.
TRON Legacy Encom UNIX machine.

The who am i command displays the name of your user and what tty you are logged in on.

deep-thought ~ # who am i
homer    pts/0        2013-07-18 22:03 (:0.0)

Using the find command to seek out a specific file in a folder.

deep-thought Desktop # find /home/homer/Desktop -name "snow*"
/home/homer/Desktop/snowden.jpg
/home/homer/Desktop/snowden.png

The lsof command lists all open files. Here I am listing all files that are opened by the mate-terminal process.

bash 10:40:38 Thu Jul 18 [homer@deep-thought $ lsof | grep mate-terminal
mate-term 7378           homer  txt       REG               8,97     313824 6030129 /usr/bin/mate-terminal
mate-term 7378           homer  mem       REG               8,97      61757  267120 /usr/share/locale/en_AU/LC_MESSAGES/mate-terminal.mo
gdbus     7378 7382      homer  txt       REG               8,97     313824 6030129 /usr/bin/mate-terminal
gdbus     7378 7382      homer  mem       REG               8,97      61757  267120 /usr/share/locale/en_AU/LC_MESSAGES/mate-terminal.mo
dconf     7378 7383      homer  txt       REG               8,97     313824 6030129 /usr/bin/mate-terminal
dconf     7378 7383      homer  mem       REG               8,97      61757  267120 /usr/share/locale/en_AU/LC_MESSAGES/mate-terminal.mo
gmain     7378 7386      homer  txt       REG               8,97     313824 6030129 /usr/bin/mate-terminal
gmain     7378 7386      homer  mem       REG               8,97      61757  267120 /usr/share/locale/en_AU/LC_MESSAGES/mate-terminal.mo

This is how to show the last reboot time on your Linux desktop or server machine.

bash 10:45:18 Thu Jul 18 [homer@deep-thought $ last reboot | head -n 1
reboot   system boot  3.8.0-25-generic Thu Jul 18 21:13 - 22:45  (01:31)

if you want to create many folders at once with the bash shell, then use this command.

bash 10:49:37 Thu Jul 18 [homer@deep-thought $ mkdir a b c d e f g

This is a very useful tip, how to only list directories with the ls command using the Linux command prompt. A very useful tip indeed.

bash 10:49:37 Thu Jul 18 [homer@deep-thought $ ls -ld */
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm a/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm b/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm c/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm d/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm e/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm f/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 10:49 pm g/
drwxrwxr-x 2 homer homer 4.0K  18-07-13 09:15 pm networking/
drwxr-xr-x 4 homer homer 4.0K  18-07-13 09:15 pm Site/

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.