It’s time to take a look at the users logged onto your Linux box. who will display the users who are logged on..
Every user on Linux is associated with a UID, a user ID. This is a decimal number that uniquely identifies a user on the system.
You have your user with a username. Type in the following for illustration of user ID and group memberships:
- We want to see all the running processes with ps. For our purpose to see all running processes we will use the switches
aux
to see all processes.a
: Select all processes except those with no session leader.
u
: Select by effective user list.
x
: Display processes in BSD format.
top
and interactive view of running processes.- Interpret the columns in the output.
- Connect back to the commandline output.
man
command with the less command to browse entire help without cropping of output.who
, to see the users logged on. Remember: Linux is a multiuser operating system.- Now type in
id <your username>
and look at the output.- id and group memberships.
You can see the user ID in the left-most part of the output: uid=..(<username>)
Let’s check users and processes
We will use the ps
command and introduce the who
and id
commands.
- Type
ps aux
to see all processes in BSD format. - Now type this again but write it to a file processes.txt. (Tip: Redirection operator >)
- Type in
who
and press Enter. You should see your own user listed. - Type
ps aux | less
to be able to scroll up and down in the list of processes.- To the left you will see the user that started the process and is therefore the owner of the process.
- Next to that you see an integer value. This is the Process ID or PID that the process is known to by the system.
Now turn your attention to the right-most column. These are the commands that initiated the processes. Yes, we skipped several columns at this stage. But you already know how to identify processes and which owners started them as well as the PIDs for the processes. You can do plenty with this.
Time to continue with lesson seven, “Hey, where is my home directory and what can I do there?“.