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


Runlevels The 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 – 0 Halt Shuts down the machine. 1 Single-User Mode Typically used for recovery. Does not configure network interfaces, start daemons, or allow non-root logins. 2 Multi-User Mode Does not configure network interfaces or start daemons. 3 Multi-User Mode with Networking Starts the system normally and provides the BASH shell. 4 Not 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

Man Every 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/file syntax # man ls shows 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.conf shows 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 pwd pwd(1p)- return working directory name pwd(1)- print name of current/working directory pwd [builtins](1)- bash built-in commands, see bash(1) pwd.h [pwd](0p)- password structure
# whatis cp cp(1)- copy files and directories cp(1p)- copy files
# whereis pwd pwd: /bin/pwd /usr/share/man/man1/pwd.1.gz /usr/share…

Finding Files & Folders

Find Syntax# find location-namefilename Examplefind /etc -name ifcfg-eth0 Find file named ifcfg-eth0 under the directory /etc.
find /home -user joe Find every file under the directory /home owned by the user joe.
find /usr -name *stat Find every file under the directory /usr ending in "stat".
find . -perm 664 Search for files with permission 644 in current directory
find / -inum1011 Searches for file with inode number 1011 in entire filesystem.

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

Setting up Network (Red Hat based System)

Segment 1 The 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 restart Restarts the network service # ifconfig Check 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= eth0 name of the device DEVICE=eth0 Device id BOOTPRO= none/static/dhcp