Showing posts from August, 2011

Sudo & ACL

If a server needs to be administered by a number of people it is normally not a good idea for them all to use the root account. This is because it becomes difficult to determine exactly who did what, when and where if everyone logs in with the same credentials. The sudo utility was designed to overcome this difficulty.
The sudo utility allows users defined in the /etc/sudoers configuration file to have temporary access to run commands they would not normally be able to due to file permission restrictions. The commands can be run as user "root" or as any other user defined in the /etc/sudoers configuration file.
The privileged command you want to run must first begin with the word sudo followed by the command's regular syntax. When running the command with the sudo prefix, you will be prompted for your regular password before it is executed. You may run other privileged commands using sudo within a five-minute period without being re-prompted for a password. All co…

Tar & RPM

Tar Files Tar files are used to create archive files. Multiple files and directories can be archived into a single file by using the tar command. Keep in mind that tar does not perform compression.Options The most commonly used options in tar are – -c create archive -x extract archive -v verbosely list processed files -f the output would be a file -t displays content of an archive -p Preserve permission -z used for gzip -j


RunlevelsThe term runlevel refers to a mode of OS initialization in Unix or similar operating systems. Runlevels are sort of like profiles that your computer uses to determine which services to launch in the background when you boot. The most commonly used runlevels are Runlevel 5 and Runlevel 3.Runlevels may vary from one OS to another. The runlevels in Red Hat Linux are – 0HaltShuts down the machine.1Single-User ModeTypically used for recovery. Does not configure network interfaces, start daemons, or allow non-root logins.2Multi-User ModeDoes not configure network interfaces or start daemons.3Multi-User Mode with Networking Starts the system normally and provides the BASH shell.4Not used/User-definable

SCP & Mount

SCP (Secured Copy)scp relies on ssh to operate. scp is used to securely copy files/directories from/to remote location. The syntax of scp is identical to cp. Syntax:  scp     -arg     source     destination
# scp  /home/sarmed
Copies the file ‘f1’ from remote host to local directory /home/sarmed# scp  f2

Copies the local file ‘f2’ to remote host in the location /home/sarmed# scp  –r  localdir Copies local ‘localdir’ to remote host in the location /home/sarmed
# scp  -P 87 /home/sarmed Same as the first example. However, this time scp connects to port 87 instead of default ssh port 22.
# scp –P 87 sarmed@ /root Same as the 4th example. Communicates with the remote host at port 87 and as user sarmed. Copies the file f4 from the remote machine to /root in local host.
Mount To access a…

Help, Output Redirection & Pipelining

ManEvery Linux system has some well documented Manuals to help users get information about commands and services. These manuals can be accessed using the command
# mancommand/filesyntax# man lsshows the manual of the command ‘ls’# man resolv.conf
shows the manual of the file ‘/etc/resolv.conf’
Some manuals contain further references at the bottom. These references usually contain page numbers that can be accessed using –# man 5 resolv.confshows page no. 5 of resolv.conf
whereis, whatis & whichwhatis displays an overview of the command. whereis & whatis have similar output that contains the location where the command is stored, as well as files related to the command.# whatis pwdpwd(1p)- return working directory namepwd(1)- print name of current/working directorypwd [builtins](1)- bash built-in commands, see bash(1)pwd.h [pwd](0p)- password structure
# whatis cpcp(1)- copy files and directoriescp(1p)- copy files
# whereis pwdpwd: /bin/pwd /usr/share/man/man1/pwd.1.gz /usr/share…

Finding Files & Folders

FindSyntax# find location-namefilenameExamplefind /etc -name ifcfg-eth0Find file named ifcfg-eth0 under the directory /etc.
find /home -user joeFind every file under the directory /home owned by the user joe.
find /usr -name *statFind every file under the directory /usr ending in "stat".
find . -perm 664Search for files with permission 644 in current directory
find / -inum1011Searches for file with inode number 1011 in entire filesystem.

LocateLocate has comparatively easy syntax, but it is recommended to run updatedb prior to running locate.
# updated# locate filenameExample – # locate passwd

Setting up Network (Red Hat based System)

Segment 1The easiest way to setup network is by using the following commands-# setup > network settings
Used for setting up network parameters# system-config-network
Used for setting up network parameters# service network restartRestarts the network service# ifconfigCheck the network parameters
Network related files/etc/sysconfig/network-scripts/This directory contains a single file for each network adapter named ifcfg-eth0, ifcfg-eth1, ifcfg-eth2 and so on. The contents of the file are:NAME= eth0name of the deviceDEVICE=eth0Device idBOOTPRO= none/static/dhcp