Learn Linux for Beginner

Friday, April 15, 2005

super user of Linux more power

Becoming a super user

The following commands are frequently used by systems administrators to keep an eye on what's going on with their systems

'last'

The command last will show you the people who have logged into the computer today and the terminals they are/were using.

If you type:

last

You may get something like this:

fredtty6 Thu Oct 5 16:55 - 20:05(3:10)
bobtty1 Thu Oct 5 still logged in(3:10)
roottty1 Thu Oct 5 16:23 - 16:43(0:20)
reboot system boot Thu Oct 5 16:22

As you can see, you worked as 'fred' for 3 hours and 10 mins. You are still working as 'bob'. You worked as 'root' for 20 minutes (probably some administration tasks) and you booted your computer at 4:22 PM.

This is a good way to see who's been using the computer if it's networked. For example, if you saw a an entry for 'satan' and you hadn't given the Prince of Darkness permission to login, you could fire off a nasty e-mail to him about mis-use of your server. His address, by the way, is "thedevil@hell.com"

'df'

'df' is a command that you're going to use a lot if you're pressed for hard disk space. Once again, there are many programs that run graphically that will inform you of the space available on your Linux partition. But this is a very good, quick, non-graphic way to keep track of your hard disk space.

If you type df

You may get something like this. (This is actually taken from a system I use for testing versions of Linux. You'll see it's somewhat pressed for space.)

Filesystem 1024-blocks UsedAvailable Capacity Mounted on
/dev/hda2 481083 408062 48174 89% /

if you start seeing a 'df' output like this, it's time to get down to your local computer shop and buy a new hard disk. Anyway, 'df' is a good way to keep track of this.

'free'

'free' is a command that you can use if you want to know how much RAM memory you have free on your system. By typing:

free

and you will get something like this


totalusedfreesharedbuffers cached
Mem: 14452 13904 548 28208 492 7312
-/+ buffers/cache: 6100 8352


Swap: 33260 1556 31704


Sometimes, if a program is running particulary slowly, you may find out that your memory usage is high using this command. Linux's memory management is quite good but a certain program may be "hogging" memory. You could exit that program and then type free again to see if it was the culprit.

'du'

'du' is the way to see how big files are. You can use it on a directory or on a particular file. This is another command I use a lot. It's probably best to use the option du -b (-b for bytes) and it will give you the exact figure in bytes. By default, 'du' shows the closest kilobyte figure. Let's look at a couple of examples:

If I type:

du people_I_owe_money.note

I may get an output like this:

194 people_I_owe_money.note

But instead, if I type:

du -b people_I_owe_money.note

I'll get:

197120 people_I_owe_money.note

As you can see, it's a big file. I owe a lot of people money. On the other hand look at the output for 'people_who_owe_me_money.note':

1 people_who_owe_me_money.note

No, that's not the kilobyte figure. That's the byte figure!

You can also use this on a directory, and it will list the files and subdirectories and give you the byte or kilobyte count, whichever you prefer

top

To show you the use of the 'top' command. Here you will see what processes are running 'top' is a good command to use when you want to see what your system's doing. 'top' is designed to show you how your CPU is being used. It will give you a pretty complete list of everything that's going on in your computer. Here's a sample output of the 'top' command:

9:09am up 4 min 2 users load average: 0.12 0.13 0.06
34 processes: 31 sleeping 3 running 0 zombie 0 stopped

CPU states: 11.1% user 0.7% system 0.0% nice 88.4% idle

Mem: 62972K av 50420K used 12552K free 22672K shrd 5312K buff

Swap: 1020116K av 3152K used 1016964K free 27536K cached


PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
332 root 12 0 4492 4184 1480 R 0 8.3 6.6 0:09 X
350 bob 4 0 13144 11M 7728 S 0 2.7 19.3 0:04 netscape
386 bob 1 0 768 768 596 R 0 0.5 1.2 0:00 top
345 bob 0 0 972 972 704 S 0 0.1 1.5 0:00 FvwmButtons
1 root 0 0 168 168 144 S 0 0.0 0.2 0:02 init
2 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kflushd
3 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kpiod
4 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kswapd
5 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 md_thread
48 root 0 0 136 120 96 S 0 0.0 0.1 0:00 update
137 bin 0 0 300 296 228 S 0 0.0 0.4 0:00 portmap
141 root 0 0 292 264 212 S 0 0.0 0.4 0:00 rpc.ugidd
157 root 0 0 512 508 412 S 0 0.0 0.8 0:00 syslogd
161 root 0 0 692 688 296 S 0 0.0 1.0 0:00 klogd
212 at 0 0 304 276 220 S 0 0.0 0.4 0:00 atd
225 root 0 0 424 416 348 S 0 0.0 0.6 0:00 inetd
258 root 0 0 580 548 428 S 0 0.0 0.8 0:00 lpd

0 Comments:

Post a Comment



<< Home