Linux Administration

Important Troubleshooting Points to Remember

What is in the path?

Recently I was in an interview for a Linux System Administration position and they asked me what the IP address was of a virtual machine they had set up for the interview. I typed in:

ifconfig | grep "addr"
and instead of getting what I expected I got back:
bash: ifconfig: command not found

I tried it a couple of more times without the grep command but got the same thing. I was so confused that the command wasn't there, I was thinking that there must be some other way of finding out an IP address that I had no idea of and finally gave up and said that I didn't know.

It occurred to me latter that the command might not have been in the path. I had typed in "vim" and it was there just previously so I wasn't thinking about checking the path. If I had typed in:

echo $PATH
I would have been able to check to see if the /sbin directory was in the path. Because if /sbin wasn't in the path all I would've had to do was type:
/sbin/ifconfig | grep "addr"
and I would have gotten the results that I was looking for.

System Information

* Processor type: (command: uname -p) * Hardware platform type: (command: uname -i) * Hostname: (command: uname -n) * CPU details: (command: hwinfo --cpu) * DSL details: (command: hwinfo --dsl) * Graphics card details: (command: hwinfo --gfxcard) * ISDN details: (command: hwinfo --isdn) * Memory: (command: hwinfo --memory) * Sound card data: (command: hwinfo --sound) * Installed Desktop Environment: (command: installed-desktops)

Networking Information

What is my IP address?

  • ifconfig Note: see above "What is in the path?"

DNS Tools

  • whois
  • nslookup

What version of Linux is running?

  • more /proc/version

How many processes are running?

  • pgrep -c -u [userName]
    +
    pgrep -c -v -u [userName]
    =
    # of running processes
  • top -b -n 1 | grep "Tasks"

User Information

Who's logged on?

  • w
  • who
  • who -a
  • finger

How many and what processes are running by [userName]?

Most of us know what "top" is and how to use it but sometimes it just doesn't give us all the information we want. There is another command that gives us a lot more information. "ps"! But that can be a little ugly at times and yet another command to use is "pgrep".

pgrep -c -u [userName]
ps $(pgrep -u [userName])

Clearing the memory cache

Note: this needs to be run by a user with root privileges.

To free pagecache:
bash: echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
bash: echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
bash: echo 3 > /proc/sys/vm/drop_caches
Designed by EverTech Consulting