Posts

Showing posts from August, 2011

Sudo & ACL

Sudo 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 used for bzip2 Syntax tar  –cvf  archive.tar   file1 file2 file3 file4 Example – suppose you have to create a tar file (example.tar) with 3 files f1, f2, f3. Then the command would be – # tar  -cvf   example.tar  f1 f2 f3 Given below are some examples 1   # tar xvf  example.tar Extracts the archive example.tar in pwd to obtain original files 2   #  tar tvf example.tar Sho...

Runlevels

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 For special purposes 5 X11 Full graphical mode managed by X-Server. 6 Reboot Reboots the computer. Setting the ...

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  192.168.10.1:/root/f1  /home/sarmed Copies the file ‘f1’ from remote host 192.168.10.1 to local directory /home/sarmed # scp  f2  192.168.10.2:/home/sarmed Copies the local file ‘f2’ to remote host 192.168.10.2 in the location /home/sarmed # scp  –r  localdir  192.168.10.2:/home/sarmed Copies local ‘localdir’ to remote host 192.168.10.2 in the location /home/sarmed # scp  -P 87 192.168.10.1:/root/f3 /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@192.168.10.1:/home/sarmed...

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 # man   command/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 & which whatis 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          ...

Finding Files & Folders

Find Syntax # find location   -name   filename Example find /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 / -inum   1011 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 none/static are used for static IP address. dhcp is used for automatic IP address. IPADDR= X.X.X.X 4 bit IP address NETMASK= X.X.X.X Netmask of the provided IP address GATEWAY= X.X.X.X IP address of the gateway server/router USERCTL= yes/no ...