Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Duties of a System Administrator


Linux involves much more than merely sitting down and turning on the machine. Linux is quite different from the most popular commercial operating systems in a number of ways, but it is no more difficult to learn.

Make no mistake: Every computer in the world has a system administrator. It may be — and probably is — that the majority of system administrators are probably those who decided what software and peripherals were bundled with the machine when it was shipped. By its very nature as a modern, multiuser operating system, Linux requires a degree of administration greater than that of less robust home market systems. By definition, the Linux system administrator is the person who has “root” access, which is to say the one who is the system’s “super user” (or root user). A standard Linux user is limited as to the things he or she can do with the underlying engine of the system.



Installing and Configuring Servers
In the Linux world, the word “server” has a meaning that is broader than you might be used to. For instance, the standard Red Hat Linux graphical user interface (GUI) requires a graphical layer called XFree86. This is a server. It runs even on a standalonemachine with one user account. It must be configured. (Fortunately, Red HatLinux has made this a simple and painless part of installation on all but the mostobscure combinations of video card and monitor; gone are the days of anguishconfiguring a graphical desktop.). Likewise, printing in Linux takes place only after you have configured a print server. Again, this has become so easy as to be nearly trivial. And Whenever a server is connected to machines outside your physical control, security issues arise. You want users to have easy access to the things they need, but you don’t want to open up the system you’re administering to the whole wide world.


Installing and Configuring Application Software
Since Linux is multiuser operating system. Each user has (or shares) an account on the system, be it on a separate machine or on a single machine with multiple accounts. While it is possible for individual users to install some applications in their home directories — drive space set aside for their own files and customizations — these applications are not available to other users without the intervention of the system administrator.

Creating and Maintaining User Accounts
An account must be created for each user and — you guessed it — no one but the system administrator may do this. That’s simple enough. But there’s more, and it involves decisions that either you or your company must make. To what may specific users have access? It might be that there are aspects of your business that make World Wide Web access desirable, but you don’t want everyone spending their working hours surfing the Web. What to do about old accounts? Perhaps someone has left the company. What happens to his or her account? You probably don’t want him or her to continue to have access to the company network. On the other hand, you don’t want to simply delete the account, perhaps to discover later that essential data resided nowhere else.



Backing Up and Restoring Files
There is a need to back up important files so that in the event of a failure of hardware, security, or administration, the system can be up and running again with minimal disruption. Only the system administrator may do this. Once you’ve decided what to back up, you need to decide how frequently you want to perform backups and whether you wish to maintain a series of incremental backups — adding only the files that have changed since the last backup — or multiple full backups, and when these backups are to be performed — do you trust an automated, unattended process?



Monitoring and Tuning Performance
System tuning is an ongoing process aided by a variety of diagnostic and monitoring tools. Some performance decisions are made at installation time, while others are added or tweaked later. A good example is the use of the hdparm utility, which can increase throughput in IDE drives considerably — but for some highspeed modes a check of system logs will show that faulty or inexpensive cables can, in combination with hdparm, produce an enormity of nondestructive but systemslowing errors.

Configuring a Secure System
For any machine that is connected to any other machine, security means hardening against attack and making certain that no one is using your machine as a platform for launching attacks against others. If you are running Web, ftp, or mail servers, it means giving access to those who are entitled to it while locking out everyone else. It means making sure that passwords are not easily guessed and not made available to unauthorized persons, that disgruntled former employees no longer have access to the system, and that no unauthorized person may copy files from your machine or machines.




Read more...

Redirection

Shell redirection operators are used to direct a program's input and output. These operators can be used to feed a program input from another application, from the command line, or even from another file. Those operators are >, >>, and < (there's another redirection operator << which is known as here operator. use this to tell the shell when to stop reading input).

The > operator is known as standard output redirection operator. When used with a program that display output, the output can be redirected to somewhere else than the standard output. For example when used with the cat command (cat is short for concatenate, is used to print one or more files to your display), the cat command will copy a file by sending its output to another file

cat first.txt > second.txt

The output of the example above will be sent to the second.txt in the current directory.

The < (standard input) redirection operator feeds information to a program as follows

cat <>

In the example above, the cat command reads the contents of the file.txt and sends its content to the standart display.

The >> redirection operator is used to append the output of an executed command to a file. The example bellow will redirect the output to the file.txt. If the file.txt doesn't exist, it will be created. If it exists, the output will be appended to the end of the file.txt.

cat first.txt >> file.txt

The standard input and output have assigned file numbers in the shell. The standard input uses the number 0, the standar output uses the number 1 while another type of output is standard error uses the number 2. Most linux command report the error to the standard error output. You can redirect the error reports to a file by doing so:

cat first.txt >> file.txt  2 >> error.log


Read more...

Finding Files and Directories

The find and locate commands can be used to search files on your system. The find command can be used to find files and directories not only based on the name or partial name of a file or directory but also from the age of the file (the time lapsed since the creation time until now), the size of the file, the last accessed time and many others. The locate command is used to quickly locate files or directories on your system. This program works very quickly ecause it uses a database of filenames instead of searching your hard drives.

To search for files or directories, specify a search path and search pattern on the command line. For example:

find /usr -name *emacs -xdev

The example above will search the /usr directory for the emacs editoer and other and other files locates th emacs program and its manual page, the -xdev option tell the command to search only your local machine (if there's any remotely mounted file system, it will be searched as well without the -xdev option and this will take a long tame).

another example would be finding files in /usr/bin directory which are accessed witihin the last 30 days. To do this, use the -atime option of the find command like so:

find /usr/bin -type f -atime +30 -print

the -type in the example above specifies that we want to find files (as opposed to a directory, symlink, device and so on).

You can also use the locate command to search for files and directories. For example, to look for any icons of the emacs text editor, use the locate command like this:

locate *icon*emacs*

The locate command searces a database called locatedb. This database is created with the updatedb command. System managers generally use the cron daemon and an updatedb crontab entry to keep the locate locatedb updated and accurate.


Read more...

Creating Symbolic Links

Symbolic links are convenient shortcuts used to link existing files or directories to files or directories with more convenient locations or names. There are times when you want to have more than one path to an existing file or directory. For example, you may want to execute a program without having to type the entire path, then you can create a link to the program from the /usr/local/bin directory.

There are two kinds of links in Linux, hard and soft links.

Soft Links


a soft link is a very small file that you create in a directory. When you execute a soft link file, it will behave as you were executing the original file. But, if you delete the original file the soft link file will be nothing and useless. Think of a soft link as a call forwarding to the original file. To create a soft link, use the ln -s command. The following example will create a softlink file to originalfile.

ln -s originalfile softlink

Soft links will work across networked file systems, mounted devices, other file systems and directories.



Hard Links


a hard link is different from a soft link in the way that if you delete the original file that a hard link is pointing to, the hard link file will remain usefull. Because when you create a hard link to a file, you are creating another directory listing to point to the same inode. The only way you can delete any file on the file system is by deleting all the hard links to that file. If you make changes to the original file, all the links will reflect that change (because they are all pointing to the same inode). Use the ln command to create a hard link (without the -s option)

ln orignalfile hardlink

hard links will only work to a file on the same disk and partition as the original.


Read more...

Getting Help

Linux distributions include documentation about nearly all the programs, commands and files installed on your hard drive. each distributions also comes with a number of commands and programs to help you learn about the systems. Some of the commands will be discussed shortly.




Man


man command is used to display the manual pages of a command, file or other Linux function (actually the manual pages are displayed using a program called less). To read a manual page of a program or command just pass the program name as the argument of the man command. The following example will show you the manual pages of the cat program

man cat

The Manual pages are located in the /usr/man directory





Whatis


Use the whatis command if you're unsure about what a program does. The whatis command will give you a short synopsis about the specified program. For example, if you issue the command whatis cal, it will return the following result

cal (1)         - dispays a calendar and the date of easter 

The synopsis is extracted from the command's manual page and is stored in a database called whatis. The database is located under the /usr/man directory and is built each day by a crontab script run each week by the makewhatis.cron script int /etc/cron.weekly directory (this script runs the makewhatis program that is found under /usr/sbin directory).





apropos


apropos command uses the whatis database to display all related mathes of the command's name. Use apropos to find related command or actions for programs installed on your system. For example, issuing the command apropos bell returns the following result (the output may be different from yours, it depends on the distribution you use)

                   beep, flash (3)            - Curses bell and screen flash routines

                       bell (n)                        - Rings a display's bell


Read more...

Shutting Down from Command Line

To reboot your system, you can use the shutdown command, which is found under the /sbin directory (to execute the shutdown command you must be root).  The shutdown command has several command-line options. use -r followed by now to reboot your system immediately (you can also reboot by using the Ctrl+Alt+Del key combination). 

shutdown -r now

You can change the now keyword to a number specifying the time in seconds when you want Linux to reboot. another options is the -h or halt to shutdown you system.  as with the -r option, -h also followed by another option specifying the time when you want Linux to shut down.

shutdown -h now

You can also use the poweroff command to turn off your system immediately. You can execute poweroff without becoming the root.


Read more...

Manage User Account

Linux was created with security in mind. That's why after you boot Linux, you'll see login and password prompts. To access Linux for the first time you can enter the root account and password (some distributions give you the option to create a user account during installation). but keep this in mind Running as root can be dangerous!


as you can accidentally delete system files or any other important files.

To create a user you need the root privilege (in some distributions you may need to prepend the sudo command everytime you want to execute a command that need root's privilege). if you're not root, you can become root with the su, you'll will be prompted to enter the root password.


if you're root. you can add a user with the command

useradd mike

that command will create a new user named mike, the useradd command will add a user entry in a file called passwd in the /etc directory. 

mike:x:1003:1003::/home/mike:/bin/sh

Some versions of useradd aks you for details about hte user, such as the user's full name and password. if yours doesn't, you can change a user password by using the passwd command. Again, you need a root privilege, except you're changing your own password.

 passwd amy

it will then propmts you for a new pasword, and then asks you to type it again to verify the change. if you've successfully change the user's password, it will be reflected in /etc/passwd entry as an encrypted string.


Read more...
top