[ Pobierz całość w formacie PDF ]
.Linux keeps ordinary users (as opposed to root) from killing other users' processes (maliciously or otherwise).For instance, if you are an ordinary user and you try to kill the init process, which always has PID=1, you will seedarkstar:~$ kill 1kill: (1) - Not ownerActually, not even root can kill the init process, although there is no error message.The init process is one of those "unkillable" processes discussed earlier, because it's such a key process.That's all for the best!Becoming Someone Else The su CommandUsually, when you want to temporarily become a different user, you will simply switch to another virtual terminal, log in as the other user, log out when you're done, and return to your "home" virtual terminal.However, there are times whenthis is impractical or inconvenient.Perhaps all your virtual terminals are already busy, or perhaps you're in a situation (such as logged on via a telephone and modem) in which you don't have virtual terminals available.In these cases, you can use the su command."su" stands for "super user." If you type su by itself, you will be prompted for the root password.If you successfully enter the root password, you will see the root # prompt, and you willhave all of root's privileges.You can also become any other user by typing su <username>.If you are root when you type su <username>, you are not asked for that user's password since in principle you could change the user's password or examine all the user's files fromthe root login anyway.If you are an "ordinary" user trying to change to another ordinary user, you will be asked to enter the password of the user you are trying to become.Although su grants you all the privileges you would get if you logged on as that user, be aware that you won't inherit that login's exact environment or run that login's startup files (if any).This means that su is not really suited to doingextended work, and it's quite unsuitable for troubleshooting problems with that login.The grep Command"What on earth does grep mean?" you ask.This is a fair question.grep must be the quintessential UNIX acronym, because it's impossible to understand even when it's spelled out in full!grep stands for Global Regular Expression Parser.You will understand the use of this command right away, but when "Global Regular Expression Parser" becomes a comfortable phrase in itself, you should probably consider taking a vacation.What grep does, essentially, is find and display lines that contain a pattern that you specify.There are two basic ways to use grep.The first use of grep is to filter the output of other commands.The general syntax is <command> | grep <pattern>.For instance, if we wanted to see every actively running process on the system, we would type ps -a | grep R.In thisapplication, grep passes on only those lines that contain the pattern (in this case, the single letter) R.Note that if someone were running a program called Resting, it would show up even if its status were S for sleeping, because grep would match the Rin Resting.An easy way around this problem is to type grep " R ", which explicitly tells grep to search for an R with a space on each side.You must use quotes whenever you search for a pattern that contains one or more blank spaces.The second use of grep is to search for lines that contain a specified pattern in a specified file.The syntax here is grep <pattern> <filename>.Be careful.It's easy to specify the filename first and the pattern second by mistake! Again,you should be as specific as you can with the pattern to be matched, in order to avoid "false" matches.SummaryBy this point you should have tried enough different Linux commands to start getting familiar (if not yet entirely comfortable) with typical Linux usage conventions.It is important that you be able to use the man pages provided online by Linux.A very good exercise at this point is to pull up man pages for all the commands we have looked at in the past two chapters: login, passwd, who, adduser, and so on.If someof the commands listed under "See also:" look interesting, by all means take a look at their man pages too!Some man pages, such as the one for bash, are extremely long.Do not plan to read them all in one sitting!In Chapter 8, we head out from "home" and poke around in the Linux filesystem.As system administrators, we should know what our hard drives contain! For instance, there are special "administrator-only"directories crammed with goodies.Several more "essential" commands will be introduced.By the end of the next chapter, you will have seen and tried most of the important "user" Linux commands and will have had a taste of some of the "administrator"commands
[ Pobierz całość w formacie PDF ]