Linux Interview Question Answer

How to Checking A File System Manually In Sun Solaris (or) take more on lost+found directory usage? Checking A File System Manually In Sun Solaris(solaris 9, solaris 10) requires the following steps to be followed : 1) Become super user. Log in as root. 2) Unmount the local file system. say /home/names 3) Use the fsck command by specifying the mount point directory or the /dev/dsk/devicenames as an argument to the command. If no argument is provided, all teh file systems with fsck pass field greater than zero (0) in the /etc/vfstab file will be checked. 4) Messages about the inconsistencies will be displayed. 5) The fsck command may not be able to fix the errors in one run. See the fsck command again, if the following message appears - "FILE SYSTEM STATE NOT SET TO OKAY or FILE SYSTEM MODIFIED" 6) Mount the repaired file system 7) Move the files in the lost+found directories to where they belong to with their proper names . We'll rename them to their original names. 8) The files and directories that we can't identify should be eventually removed. This saves space. How to check the amount of RAM in system? Issue teh following Unix/Linux command to check the amount of RAM in the server. Issue the following command as root user. # grep MemTotal /proc/meminfo MemTotal: 1034680kB Memtotal refers to the total RAM space in the machine. Minimum RAM : 1024MB Talk more on Linux slocate utility:- The slocate utility, is a secure version of locate.It searches for files on the local system. $slocate filename Before we can use slocate the updatedb utility must build/update the slocate database.Typically the database is updated once a day by a cron script. What is linux out of memory killer? Linux out of memory OOM killer is a feature enabled by default in Linux. This is Out of memory (OOM) killer.It is associated with memory management.It is used to protect system from hang by terminating processes which consume high memory resources. Memory allocation in Linux is the task of kernel. If the kernel is not able to find the memory space needed to allocate to the process, it puts in use user data pages on swap out queue.If it happens that virtual memory can not allocate sufficient space, out of memory killer (OOM killer) starts killing user space processes. # echo "0" > /proc/sys/vm/oom-kill (turns off oom killer) # echo "1" > /proc/sys/vm/oom-kill (turns on/enables oom killer Say something on Built-in Linux Commands:- Built-in Commands are the commands that are built into a shell.they do not fork a new process when we execute them.The built-ins vary depending on the type of the shell. A brief listing of various built-ins is given below: tcsh Built-ins : type - gives the type of the command given as argument.For eg type cat will give the output as cat is hashed(/bin/cat) read - Scripts can accept input from the user and store them in variables. exec - executes a command.It has two main purposes:to run a command without creating a new process and to redirect a file descriptor -including standard input,output or error -of a shell script from within the script. trap - catches a signal.A signal is a report to a process about a condition.Linux uses signals to report interrupts generated by users (eg : pressing a interrupy key),bad system calls,broken pipes,illegal instructions etc.Trap catches,one or more signals allowing us to direct the actions a script takes when it receives a specified signal. kill - Aborts a process.the kill sends a signal to a process or a job. getopts - Parses options.Parses command-line arguments,thereby making it easier to write programs that follow Linux argument conventions. bash(Bourne Again shell) Builtins : : - Returns 0 or true(null built-in) .(dot) - Executes a shell script as a part of the current process bg - Puts a suspended job in the background break - Exits from a looping control structure cd - Changes to another working directory continue - Starts with the next iteration of looping control structure echo - Displays its arguments eval - scans and evaluates the command-line exec - Executes a shell-script or a program in place of the current process exit - Exits from te current shell.Same as CONTROL-D from an interactive shell. export - Places the value of the variable in the calling environment. fg - brings a job from the background into the foreground getopts - Parses arguments to a shell script jobs - Displays list of background jobs kill - sends a signal to a process or job pwd - displays the name of the working directory.Print working directory. read - Reads a line from the standard input readonly - declares a variable to be readonly set - set shelflags or command-line argument variables,with no arguments,lists all variables. shift - promotes each command-liargument test - compares arguments times - displays total times for the current shell and its children trap - traps a signal type - displays how eachrgument would be interpreted as a command umask - returns the value of the file-creation mask unset - Removes a variable or a function wait - Waits for a bcakground process to terminate. How to Monitor system with glanceplus HP-UX command? In HP-UX (HP unix) we have a package to monitor the system. It is a system-monitoring tool.Glanceplus is a package commonly used by the system administrators and DBA's to monitor the memory, disk I/O and CPU performance. $glance -m Above command invokes glanceplus session in text mode. CPU,memory, disk and swap usage are summarized in the top section. The middle of the display gives a detailed memory report. The bottom of the report gives a short summary of memory usage. $glance -c - details on CPU usage $glance -d - disk usage details gpm is a graphical user interface. It is an attractive and highly useful GUI. Say something on Network Utilities in UNIX/LINUX:- Following are some important UNIX/LINUX utilities used for networking: 1) ftp - transfers files over a network 2) rcp - copies one or more files to or from a remote system 3) rlogin - logs in on a remote system 4) rsh - executes command on a remote system. This is popularly used by DBA's while creating scripts for single-instance database as well as RAC (Real Application Cluster) operational tasks automation such as cloning automation, backups etc 5) scp - securely copies one or more files to or from a remote system. This is an enhancement over rcp and is used to address/overcome the security threats associated with rcp 6) ssh - securely executes a command on the remote system. This is an enhancement over rsh and is used to address/overcome the security threats associated with rsh 7) telnet - connects to remote system over a network. Most popularly used method for connecting to a remote system. Are there UNIX/LINUX Utilities That are Programming Tools? Certain UNIX/LINUX Utilities can be used a programming tools : configure - configures source code automatically gcc - compiles c and c++ programs make - keeps a set of programs current. popularly referred to as build / make build. Most popular tool used in practice. Ubuntu Linux elinks Package Installation :- In ubuntu linux we can make use of the command ubuntu. For this command to function properly we need to install elikns packages including elinks,elinks-data,elinks-lite root@ubuntu:~# apt-get install elinks* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting prelink for regex 'elinks*' Note, selecting elinks-data for regex 'elinks*' Note, selecting elinks-doc for regex 'elinks*' Note, selecting elinks-lite for regex 'elinks*' Note, selecting elinks for regex 'elinks*' Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: elinks: Conflicts: elinks-lite but 0.12~pre5-2ubuntu1 is to be installed elinks-data: Conflicts: elinks-lite but 0.12~pre5-2ubuntu1 is to be installed elinks-lite: Conflicts: elinks but 0.12~pre5-2ubuntu1 is to be installed Ubuntu Linux Dig DNS Lookup Command :- It is possible to determine the DNS (Domain Name Service) information based on the IP address. We can get details on the DNS using IP through reverse lookup process. The ubuntu linux command can be used to get this detail. It can be used as follows. root@ubuntu:~# dig -x 192.168.25.234 ; <<>> DiG 9.7.0-P1 <<>> -x 192.168.25.234 ;; global options: +cmd ;; Got answer: ;; ->>HEADER< ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;131.25.168.223.in-addr.arpa. IN PTR ;; Query time: 32 msec ;; SERVER: ;; WHEN: Tue Sep 14 10:44:07 2010 ;; MSG SIZE rcvd: 45 Install NFS Package Ubuntu Linux :- Network File System popularly called NFS is a service in linux. We can start using NFS in ubuntu linux upon installing nfs-kernel-server package. We can make use of apt-get install command to install this package. root@ubuntu:~# apt-get install nfs-kernel-server Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libgssglue1 libnfsidmap2 librpcsecgss3 nfs-common portmap The following NEW packages will be installed: libgssglue1 libnfsidmap2 librpcsecgss3 nfs-common nfs-kernel-server portmap 0 upgraded, 6 newly installed, 0 to remove and 41 not upgraded. Need to get 492kB of archives. After this operation, 1,524kB of additional disk space will be used. Do you want to continue [Y/n]? Y Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main libgssglue1 0.1-4 [22.4kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/main libnfsidmap2 0.23-2 [29.1kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/main librpcsecgss3 0.19-2 [33.1kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/main portmap 6.0.0-1ubuntu2 [37.2kB] Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/main nfs-common 1:1.2.0-4ubuntu4 [212kB] Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid/main nfs-kernel-server 1:1.2.0-4ubuntu4 [158kB] Fetched 492kB in 1s (266kB/s) Preconfiguring packages ... Selecting previously deselected package libgssglue1. (Reading database ... 125014 files and directories currently installed.) Unpacking libgssglue1 (from .../libgssglue1_0.1-4_i386.deb) ... Selecting previously deselected package libnfsidmap2. Unpacking libnfsidmap2 (from .../libnfsidmap2_0.23-2_i386.deb) ... Selecting previously deselected package librpcsecgss3. Unpacking librpcsecgss3 (from .../librpcsecgss3_0.19-2_i386.deb) ... Selecting previously deselected package portmap. Unpacking portmap (from .../portmap_6.0.0-1ubuntu2_i386.deb) ... Selecting previously deselected package nfs-common. Unpacking nfs-common (from .../nfs-common_1%3a1.2.0-4ubuntu4_i386.deb) ... Selecting previously deselected package nfs-kernel-server. Unpacking nfs-kernel-server (from .../nfs-kernel-server_1%3a1.2.0-4ubuntu4_i386.deb) ... Processing triggers for man-db ... Processing triggers for ureadahead ... Setting up libgssglue1 (0.1-4) ... Setting up libnfsidmap2 (0.23-2) ... Setting up librpcsecgss3 (0.19-2) ... Setting up portmap (6.0.0-1ubuntu2) ... portmap start/running, process 24755 Setting up nfs-common (1:1.2.0-4ubuntu4) ... Creating config file /etc/idmapd.conf with new version Creating config file /etc/default/nfs-common with new version Adding system user `statd' (UID 115) ... Adding new user `statd' (UID 115) with group `nogroup' ... Not creating home directory `/var/lib/nfs'. statd start/running, process 24978 gssd stop/pre-start, process 25003 idmapd stop/pre-start, process 25031 Setting up nfs-kernel-server (1:1.2.0-4ubuntu4) ... Creating config file /etc/exports with new version Creating config file /etc/default/nfs-kernel-server with new version * Exporting directories for NFS kernel daemon... [ OK ] * Starting NFS kernel daemon [ OK ] Processing triggers for libc-bin ... ldconfig deferred processing now taking place Linux Ubuntu IP Address Information :- In the ubuntu linux it is possible to get information on IP address using the ifconfig command. We can use ifconfig command with -a option to get more details root@ubuntu:~# ifconfig -a eth0 Link encap:Ethernet HWaddr inet addr: Bcast:192.168.25.255 Mask:255.255.255.0 inet6 addr: Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:21428 errors:0 dropped:0 overruns:0 frame:0 TX packets:5781 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14694291 (14.6 MB) TX bytes:382100 (382.1 KB) Interrupt:19 Base address:0x2000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:162 errors:0 dropped:0 overruns:0 frame:0 TX packets:162 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:12656 (12.6 KB) TX bytes:12656 (12.6 KB) Ubuntu Linux Apache ServiceOnce we install apache package in ubuntu linux using the apt-get utility, we can monitor th:- e status of apache service. This command verifies that apache has been successfully installed, up and running in the ubuntu linux. root@ubuntu:~# ps -ef|grep apache root 16907 1 0 11:07 ? 00:00:00 /usr/sbin/apache2 -k start www-data 16910 16907 0 11:07 ? 00:00:00 /usr/sbin/apache2 -k start www-data 16911 16907 0 11:07 ? 00:00:00 /usr/sbin/apache2 -k start www-data 16912 16907 0 11:07 ? 00:00:00 /usr/sbin/apache2 -k start root 17016 15480 0 11:09 pts/0 00:00:00 grep --color=auto apache Above command lists the processes and we can match the apache service using the "grep apache" keyword. We can also locate the location of apache binary as follows : root@ubuntu:~# which apache2 /usr/sbin/apache2 Apache runs as a service in Linux and we can make use of the command service to get details on apache process. root@ubuntu:~# service apache2 status Apache is running (pid 16907). Ubuntu Linux Install Apache :- Apache is the most popular web server.LAMP stack as it is popularly called refers to Linux,Apache,MySQL,PHP/Perl forms the basic technology stack upon which we build web applications. We can install apache package using the Linux utility apt-get with the option install. Here is the step used to install apache in ubuntu linux. root@ubuntu:~# apt-get install apache2 Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap Suggested packages: apache2-doc apache2-suexec apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap 0 upgraded, 9 newly installed, 0 to remove and 41 not upgraded. Need to get 3,328kB of archives. After this operation, 10.1MB of additional disk space will be used. Do you want to continue [Y/n]? Y ...................................................................................... 3.9+dfsg-3build1 [27.1kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/main libaprutil1-ldap 1.3.9+dfsg-3build1 [25.1kB] Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/main apache2.2-bin 2.2.14-5ubuntu8 [2,622kB] 15% [5 apache2.2-bin 259kB/2,622kB 9%] ............................................................................................ Selecting previously deselected package apache2.2-bin. Unpacking apache2.2-bin (from .../apache2.2-bin_2.2.14-5ubuntu8_i386.deb) ... Selecting previously deselected package apache2-utils. Unpacking apache2-utils (from .../apache2-utils_2.2.14-5ubuntu8_i386.deb) ... Selecting previously deselected package apache2.2-common. Unpacking apache2.2-common (from .../apache2.2-common_2.2.14-5ubuntu8_i386.deb) ... Selecting previously deselected package apache2-mpm-worker. Unpacking apache2-mpm-worker (from .../apache2-mpm-worker_2.2.14-5ubuntu8_i386.deb) ... Selecting previously deselected package apache2. Unpacking apache2 (from .../apache2_2.2.14-5ubuntu8_i386.deb) ... Processing triggers for man-db ... Processing triggers for ufw ... Processing triggers for ureadahead ... Setting up libapr1 (1.3.8-1build1) ... Setting up libaprutil1 (1.3.9+dfsg-3build1) ... Setting up libaprutil1-dbd-sqlite3 (1.3.9+dfsg-3build1) ... Setting up libaprutil1-ldap (1.3.9+dfsg-3build1) ... Setting up apache2.2-bin (2.2.14-5ubuntu8) ... Setting up apache2-utils (2.2.14-5ubuntu8) ... Setting up apache2.2-common (2.2.14-5ubuntu8) ... Enabling site default. Enabling module alias. Enabling module autoindex. Enabling module dir. Enabling module env. Enabling module mime. Enabling module negotiation. Enabling module setenvif. Enabling module status. Enabling module auth_basic. Enabling module deflate. Enabling module authz_default. Enabling module authz_user. Enabling module authz_groupfile. Enabling module authn_file. Enabling module authz_host. Enabling module reqtimeout. Setting up apache2-mpm-worker (2.2.14-5ubuntu8) ... * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [ OK ] Setting up apache2 (2.2.14-5ubuntu8) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place root@ubuntu:~# Yum Installtion Linux:- I installed vmplayer and created ubuntu 10.04LTS virtual machine. I logged into system as root and tried installing a package using yum. root@ubuntu:~# yum install libpng The program 'yum' is currently not installed. You can install it by typing: apt-get install yum This can be fixed as follows root@ubuntu:~# apt-get install yum Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: liblua5.1-0 librpm0 librpmbuild0 librpmio0 python-rpm python-sqlite python-sqlitecachec python-urlgrabber rpm rpm-common rpm2cpio Suggested packages: python-sqlite-dbg alien elfutils rpm-i18n The following NEW packages will be installed: liblua5.1-0 librpm0 librpmbuild0 librpmio0 python-rpm python-sqlite python-sqlitecachec python-urlgrabber rpm rpm-common rpm2cpio yum 0 upgraded, 12 newly installed, 0 to remove and 41 not upgraded. Need to get 5,916kB of archives. After this operation, 9,769kB of additional disk space will be used. Do you want to continue [Y/n]? Y ...................tting up librpmbuild0 (4.7.2-1lbuild1) ... Setting up python-sqlite (1.0.1-7ubuntu1) ... Setting up python-urlgrabber (3.1.0-5ubuntu1) ... Setting up rpm2cpio (4.7.2-1lbuild1) ... Setting up rpm (4.7.2-1lbuild1) ... Trying rpm init... Setting up python-rpm (4.7.2-1lbuild1) ... Setting up python-sqlitecachec (1.1.2-1ubuntu1) ... Processing triggers for python-central ... Setting up yum (3.2.25-1ubuntu2) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place Processing triggers for python-support ... Check Yum Installation :- Yum the popular Linux utility helps us in installing linux dependency packages. It is possible to check and verify if latest version of yum has been installed in the system as follows. root@ubuntu:~# apt-get install yum Reading package lists... Done Building dependency tree Reading state information... Done yum is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 41 not upgraded. Give details on Logging Into Zone Solaris:- Sun Solaris (Solaris 10) - Logging in to a Zone can be performed as the root user/ super user (# prompt).Root user role can be assumed directly or as a role with RBAC (Role Based Access Control) profile "Zone Management".They can log directly into a zone from the global zone without having to supply a password.The system administrators will use "zlogin" command to log into the zone.To obtain information about the name of the zone the command "zonename" is run.To log in to a zone , perform the following steps: 1) Assume root user role $ su - root 2) Use zlogin command to log into the zone # zlogin testzonelogin 3) Obtain the name of the zone using zonename command # zonename -- testzonelogin 4) Exit the zone using exit command : # exit Phases of a boot process : Boot process has the following phases : 1) Boot PROM Phase 2) Boot programs phase 3) Kernel initialization phase 4) init phase 5) svc.startd phase What happens in each and every phase? A brief description of what happens in every phase is described below : 1) Boot PROM Phase : After we power on the system, PROM displays : 1) system identification information 2) runs self-diagnostics to verify systems hardware and memory 3) Loads primary boot program bootblk from its location on the boot device into the memory 2) Boot Programs Phase : 1) Primary boot program bootblk identifies and executes the seconay boot program ufsboot from the UNIX File system and loads it into the memory 2) ufsboot program loads the two part kernel 3) Kernel Initialization phase : 1) Kernel initializes itself 2) Kernel starts loading modules using usfboot to read the files 3) Kernel loads enough modules to mount the root file system 4) ufsboot is out of picture now 5) Kernel unmaps ufsboot and starts using its own resources 4) init phase : 1) Kernel creates a user process and starts /sbin/init process 2) /sbin/init reads the /etc/inittab file for instructions on starting other processes 3) One such process is svc.startd daemon 4) svc.startd is located at /lib/svc/bin/svc.startd 5) svc.startd Phase : 1) svc.startd starts the system services 2) svc.startd boots the system to appropriate milestone 3) System services are started by svc.startd daemon 4) System services are - checks and mounts filesystem, configure the network and devices, initiates various startup processes and performs system maintenance tasks, executes legacy run control script (rc scripts) for compatability Phases in boot and boot sequence is as follows : bootblk->ufsboot->kernel root file system->/sbin/init process->svc.startd daemon Displaying process information Sun Solaris: Sun Solaris (solaris 9, solaris 10) - Displaying process information is used to obtain information about the processes. 1) Login as root user / super user $ su - root 2) To display active processes use ps command : # ps -ef 3) Open another new window and display active processes using the prstat command : # prstat ps command - snapshot of active processes prstat - gives a continuous updated display. To display prstat command type "q" 4) To display dtlogin processes use pgrep command. We obtain PID, dtlogin process and all of its child processes : # pgrep dtlogin 5) To display the ancestary process of a process use ptree command : # ptree 6) Start the process manager (to make it a background process use &) : # sdtprocess & Process manager windows updates periodically. In the sample field at the top of the window, change the sample period from 30 to 3 seconds. We can sort the processes by ID by clicking on the ID button in the header. crontab Linux/UNIX Scheduling : To automate various tasks they can be scripted and included in crontab.We can create user specific crontabs as follows: $crontab -e To list the entries we issue : $crontb -l The directory /etc/corn.d contins the following files - cron.allow, cron.deny By default cron.deny has the list of usernames who are denied cron access. This list is a roster of default system users like smtp. etc cron.allow permits the user listed in file to access the crontab. In such cases cron.allow precedes over cron.deny (i.e) cron.deny doesn't take effect.For scheduling routine jobs we use crontab. For onetime scheduling we make use of at Linux Utility OS Level Security UNIX OS Security - User Logins - Password Rules :- Security threat starts at the user level. So it is very important to keep the systems(information and application systems) secured by restricting access to proper users.Identifying, monitoring, disabling logins play a major role in user access management.It is the essential duty performed by a security engineer/security administrator/security professional/Infosec Professional/UNIX/LINUX/HP-UX/AIX/Solaris System administrator.Primary step an organization takes towards security is creating internal policies which are standardized rules that govern the organizations : 1) Passwords must be kept confidential. This happens by frequent change of password according to preset rules. For example, some organizations demand quarterly change of root(super user) password. So, admins must change the password once in three m onths. They write the password information and seal it. It will be handed over to appropriate higher official like Managers/CFO/CTO/CIO(Chief Information Officer) for emergency purposes 2) Users should not share their user id and password. Password disclosure is a serious security violation and may lead to loss of information 3) Passwords should not be saved in locations transparent to all users 4) Users should access applications and systems only using the username and passwords assigned to them 5) User IDs must be unique. There can be automated programs, scripts, systems to create unique user id 6) User IDs can be created with users first and lastname as its components. In most of the cases it is of the form first letter of first name+last name, first three letters of first name+last name etc 7) Passowrds must be used for accessing local and remote systems. Password ageing policies must be enforced which demands the users to change the password once in quarter/once in a month etc 8) Concurrent login sessions is not permitted 9) User logins are tracked and exceptions recorded must be answered properly 10) Automatic terminal timeouts must be enabled. This might be screensaver lock option in case of user inactivity for 15 consecutive minutes 11) Three consecutive failure login attempts are permitted. User ids must be locked after that 12) Users must maintain their passwords confidentially Log In As Root User :- In Linux/UNIX servers it is recommended to login as normal user. Then we need to make use of the su - root command to switch as root/superuser. This is a security measure mandated by popular standards like SOX,HIPAA,PCI etc. A Linux/unix system administrator is expected to keep the servers secured. learnersreference@ubuntu:~$ su - root Password: root@ubuntu:~# whoami root How to Shut Down Installing Solaris 10 OS On a Running System? Shutting Down and Installing Solaris 10 OS On a Running System involves the following steps : 1) Become the root user / super user (# prompt) 2) Shutdown the system by issuing shutdown command. This brings the system down to single user state by halting the window system. We'll be in a single root prompt on the console. 3) Issue the halt command. This command puts us into the PROM(Programmable Read Only Memory). We'll receive the ok> prompt 4) Insert the Solaris 10 CD-ROM 1 into the CD-ROM player. Boot from the CD-ROM. We can also use Solaris 10 DVD. 5) At the ok prompt type the boot command with cdrom option. ok> boot cdrom This command will start the default GUI installation on a bit-mapped console. Our system should have atleast 384MB RAM installed.If the system has less memory ( boot cdrom - nowin This is CLI (command-line interface) version of the installation program. If the console doesn't support graphics, we'll automatically be put into the CLI version of the installation. 6) Select various options - language, network configuration parameters etc. 7) Set the root password. Say something on VsVim Visual Studio Vim Emulation Layer:- Vim emulation layer for visual studio 2010 is vsvim. Vsvim is available on the extension manager in Visual studio. It can also be downloaded directly. Some of the new features of Vsvim are as follows 1) Motions - G,gg,H,M,L,f,t,F,T 2) Options - startofline, visualedit, visualbell,hlsearch,ignorecase,smartcase 3) Visual Mode - put,<,>,~, normal mode motions 4) Normal mode motions - D,~,N,Ctrl+F,Ctrl+B 5) Command mode - qa Some interesting issues have been addressed in vsvim -- VsVim will look for .vsvimrc before .vimrc -- We can close a file n insert mode -- F1 keys can be properly used VsVim for Visual Studio 2010 can be downloaded directly Give details on Oracle Solaris10 Terminal Type Ttymon:- Terminal type determines the way in which information is exchanged between the client computer and the host server. We make use of terminal programs like telnet,ssh,rsh to connect to the server to get more information. We can determine if the information received can be displayed at the client side in the intented format.This can be set initially to prevent crazy output behaviour. Some clients don't support cursor movements, displaying certain objects etc. so, we can set it to a type that is compatible and can display the output. The most popular terminal types are DEC(Digital Equipment Corporation) VT100, Windows xterm etc. Here is the step by step instruction on setting ttymon in oracle solaris 10. We set it to terminal type xterm. It is to be noted that we need to restart the service for changes to take effect immediately. If not we have to logout of the session and login again. 1) Determine the terminal type set in your machine. In my case it is xterm. For demo purpose I'm going to make it vt100. #env |grep TERM color-term=gnome-terminal TERM=xterm 2) Set the terminal type to vt100 # svccfg -s console-login setprop ttymon/terminal_type = "vt100" 3) Restart the service for the changes to take effect soon #svcadm restart svc:/system/console-login:default How to obtain Oracle Solaris OS Information? Oracle solaris 10 has set of commands to get more details of operating system including its architecture,type etc. Here is the simple os related commands #isainfo -k i 386 Oracle Solaris the OS rebranded after the oracle sun microsystems merger can be installed as virtual machine in local desktop. If you want to learn more on oracle solaris 10 administration look at the documentation link starting from basic administration,network services to advanced solaris SAN configuration,advanced multipathing and so on. http://docs.sun.com/app/docs/coll/47.16 Ubuntu Linux 10.04 hformat Command hfsutils Package:- The command to format a hard disk, create disk partitions that could be mounted and made use of is the hformat command in ubuntu linux. In major flavours of linux including sun solaris(now oracle solaris)the command used for formatting purpose is the format command. Also fdisk is another linux command used for similar purpose. For using hformat command we need to install hfsutils package using the apt-get utility with this install option root@ubuntu:~# hformat The program 'hformat' is currently not installed. You can install it by typing: apt-get install hfsutils root@ubuntu:~# apt-get install hfsutils Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: hfsutils-tcltk The following NEW packages will be installed: hfsutils 0 upgraded, 1 newly installed, 0 to remove and 41 not upgraded. Need to get 77.9kB of archives. After this operation, 238kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main hfsutils 3.2.6-11build3 [77.9kB] Fetched 77.9kB in 0s (84.9kB/s) Selecting previously deselected package hfsutils. (Reading database ... 125687 files and directories currently installed.) Unpacking hfsutils (from .../hfsutils_3.2.6-11build3_i386.deb) ... Processing triggers for man-db ... Setting up hfsutils (3.2.6-11build3) ... root@ubuntu:~# hformat Usage: hformat [-f] [-l label] path [partition-no] Ubuntu Linux Set Root Password Upon Installation:- I installed and created ubuntu linux in virtual machine recently. We can create a new password for the superuser also called as root user. We make use of sudo command to proceed with this process. learnersreference@ubuntu:~$ sudo passwd root Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully learnersreference@ubuntu:~$ su - root Password: root@ubuntu:~# who -u learnersreference tty7 2010-09-26 19:32 old 15895 (:0) learnersreference pts/0 2010-09-26 19:59 . 16364 (:0.0) root@ubuntu:~# whoami root mpstat command ubuntu linux sysstat package:- There are plenty of commands used to monitor and manage processes in the ubuntu linux OS. One such command used to obtain detail on memory is the mpstat. It is mandatory to install sysstat package using apt-get install utility. Here are the sequence of steps. root@ubuntu:~# mpstat The program 'mpstat' is currently not installed. You can install it by typing: apt-get install sysstat root@ubuntu:~# apt-get install sysstat Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: isag The following NEW packages will be installed: sysstat 0 upgraded, 1 newly installed, 0 to remove and 63 not upgraded. Need to get 253kB of archives. After this operation, 1,163kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main sysstat 9.0.6-2 [253kB] Fetched 253kB in 3s (81.9kB/s) Preconfiguring packages ... Selecting previously deselected package sysstat. (Reading database ... 124142 files and directories currently installed.) Unpacking sysstat (from .../sysstat_9.0.6-2_i386.deb) ... Processing triggers for man-db ... Processing triggers for doc-base ... Processing 26 changed 1 added doc-base file(s)... Registering documents with scrollkeeper... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Setting up sysstat (9.0.6-2) ... Creating config file /etc/default/sysstat with new version update-alternatives: error: no alternatives for sar. update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto mode. root@ubuntu:~# mpstat Linux 2.6.32-24-generic (ubuntu) 09/27/2010 _i686_ (1 CPU) 12:52:28 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 12:52:28 PM all 0.70 0.84 1.87 1.28 0.07 0.07 0.00 0.00 95.16 ptree command ubuntu linux adacontrol package:- In ubuntu linux we can make use of ptree commad to obtain details on parent-child process relationship in the form of tree structure. We need to install adacontrol package using apt-get utility with install option for the ptree command to function properly. root@ubuntu:~# ptree The program 'ptree' is currently not installed. You can install it by typing: apt-get install adacontrol root@ubuntu:~# apt-get install adacontrol Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: ada-reference-manual gnat gnat-4.4 gnat-4.4-base gnat-gps gnat-gps-doc libasis2008 libgnat-4.4 libgnatprj4.4 libgnatvsn4.4 libgtkada2.14.2 libtemplates-parser11.5 Suggested packages: gnat-3.2 gnat-4.4-doc The following NEW packages will be installed: ada-reference-manual adacontrol gnat gnat-4.4 gnat-4.4-base gnat-gps gnat-gps-doc libasis2008 libgnat-4.4 libgnatprj4.4 libgnatvsn4.4 libgtkada2.14.2 libtemplates-parser11.5 0 upgraded, 13 newly installed, 0 to remove and 63 not upgraded. Need to get 36.4MB of archives. After this operation, 122MB of additional disk space will be used. Do you want to continue [Y/n]? Y Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/universe ada-reference-manual 20021112web-3 [2,660kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/universe gnat-4.4-base 4.4.3-1ubuntu1 [132kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgnat-4.4 4.4.3-1ubuntu1 [1,118kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgnatvsn4.4 4.4.3-1ubuntu1 [338kB] Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgnatprj4.4 4.4.3-1ubuntu1 [545kB] Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid/universe gnat-4.4 4.4.3-1ubuntu1 [13.3MB] Get:7 http://us.archive.ubuntu.com/ubuntu/ lucid/universe gnat 4.4+1ubuntu1 [2,040B] Get:8 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libasis2008 2008-4build1 [634kB] Get:9 http://us.archive.ubuntu.com/ubuntu/ lucid/universe adacontrol 1.12~b1-1 [2,232kB] Get:10 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgtkada2.14.2 2.14.2-1ubuntu1 [1,184kB] Get:11 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libtemplates-parser11.5 11.5-3 [193kB] Get:12 http://us.archive.ubuntu.com/ubuntu/ lucid/universe gnat-gps 4.3-5ubuntu1 [6,154kB] Get:13 http://us.archive.ubuntu.com/ubuntu/ lucid/universe gnat-gps-doc 4.3-5ubuntu1 [7,919kB] Fetched 36.4MB in 1min 9s (525kB/s) Selecting previously deselected package ada-reference-manual. (Reading database ... 124184 files and directories currently installed.) Unpacking ada-reference-manual (from .../ada-reference-manual_20021112web-3_all.deb) ... Selecting previously deselected package gnat-4.4-base. Unpacking gnat-4.4-base (from .../gnat-4.4-base_4.4.3-1ubuntu1_i386.deb) ... Selecting previously deselected package libgnat-4.4. Unpacking libgnat-4.4 (from .../libgnat-4.4_4.4.3-1ubuntu1_i386.deb) ... Selecting previously deselected package libgnatvsn4.4. Unpacking libgnatvsn4.4 (from .../libgnatvsn4.4_4.4.3-1ubuntu1_i386.deb) ... Selecting previously deselected package libgnatprj4.4. Unpacking libgnatprj4.4 (from .../libgnatprj4.4_4.4.3-1ubuntu1_i386.deb) ... Selecting previously deselected package gnat-4.4. Unpacking gnat-4.4 (from .../gnat-4.4_4.4.3-1ubuntu1_i386.deb) ... Selecting previously deselected package gnat. Unpacking gnat (from .../gnat_4.4+1ubuntu1_i386.deb) ... Selecting previously deselected package libasis2008. Unpacking libasis2008 (from .../libasis2008_2008-4build1_i386.deb) ... Selecting previously deselected package adacontrol. Unpacking adacontrol (from .../adacontrol_1.12~b1-1_i386.deb) ... Selecting previously deselected package libgtkada2.14.2. Unpacking libgtkada2.14.2 (from .../libgtkada2.14.2_2.14.2-1ubuntu1_i386.deb) ... Selecting previously deselected package libtemplates-parser11.5. Unpacking libtemplates-parser11.5 (from .../libtemplates-parser11.5_11.5-3_i386.deb) ... Selecting previously deselected package gnat-gps. Unpacking gnat-gps (from .../gnat-gps_4.3-5ubuntu1_i386.deb) ... Selecting previously deselected package gnat-gps-doc. Unpacking gnat-gps-doc (from .../gnat-gps-doc_4.3-5ubuntu1_all.deb) ... Processing triggers for install-info ... install-info: warning: no info dir entry in `/usr/share/info/adacontrol_ug.info.gz' Processing triggers for doc-base ... Processing 6 added doc-base file(s)... Registering documents with scrollkeeper... Processing triggers for man-db ... Setting up ada-reference-manual (20021112web-3) ... Ignoring install-info called from maintainer script The package ada-reference-manual should be rebuilt with new debhelper to get trigger support Setting up gnat-4.4-base (4.4.3-1ubuntu1) ... Setting up libgnat-4.4 (4.4.3-1ubuntu1) ... Setting up libgnatvsn4.4 (4.4.3-1ubuntu1) ... Setting up libgnatprj4.4 (4.4.3-1ubuntu1) ... Setting up gnat-4.4 (4.4.3-1ubuntu1) ... Setting up gnat (4.4+1ubuntu1) ... Setting up libasis2008 (2008-4build1) ... Setting up adacontrol (1.12~b1-1) ... Setting up libgtkada2.14.2 (2.14.2-1ubuntu1) ... Setting up libtemplates-parser11.5 (11.5-3) ... Setting up gnat-gps (4.3-5ubuntu1) ... Setting up gnat-gps-doc (4.3-5ubuntu1) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place root@ubuntu:~# ptree PTREE: prints the logical nesting of ASIS elements for a unit Usage: ptree [-sS] [-p <project_file>] [: <line_number>[: <column_number>]] -- <ASIS_Options> or: ptree -h Options: -h prints this help message -p file specify an emacs ada-mode project file (.adp) -s process specifications only -S print span of each element Ubuntu Linux Synaptic Package Manager: The packages in a Linux server can be installed using the command-line tool apt-get. We can make use of the GUI tool synaptic manager for package installation,maintenance. This can be accessed by Clicking on System->Administration->Synaptic Package Manager. This GUI for apt-get makes package installation,kernel compilation pretty easy and simple. Identify Release Ubuntu Linux:- Ubuntu linux the most popular opensource and user friendly linux is gaining huge popularity. In major Linux flavours it is possible to identify linux release using the simple command cat /etc/release ; more /etc/release . The release file under /etc directory will contain the needed information. These steps don't work in ubuntu linux. Here are the simple steps to identify the release of ubuntu linux. This doesn't work as mentioned above root@ubuntu:~# more /etc/release /etc/release: No such file or directory root@ubuntu:~# echo $RELEASE The above command doesn't work as there is no default environment variable by name RELEASE. Extract the information as follows: root@ubuntu:~# lsb_release -sr 10.04 If we want to extract this detail using a shell script here is the simple code #/usr/bin/sh export RELEASE=$(lsb_release -sr) echo $RELEASE Output - 10.04 I've installed 10.04 LTS (Long Term Support) ubuntu linux version. This information is correctly extracted now. Linux Directory Subdirectories One step Not Allowed:- I tried creating directory and sub-directories (more than one level of directory) in a single step with mkdir command. I'm making use of ubuntu Linux 10.04 LTS (core code - lucid - can be obtained using lsb_release -c command). I got the following error. This is an interesting Linux interview question that you can expect in many technical interviews. Create the directories in sequence to solve the problem root@ubuntu:~# mkdir development/kernel/lucid
mkdir: cannot create directory `development/kernel/lucid': No such file or directory
root@ubuntu:~# mkdir development
root@ubuntu:~# mkdir development/kernel (or) cd development ; mkdir kernel
root@ubuntu:~# mkdir development/kernel/lucid (or) cd development/kernel ; mkdir lucid
Finger command:- Finger command is a security risk.It is disabled by system administrator where security risk is a concern.This utility gives information that can be used by a malicious user to break into the system.We can use finger to display the list of users who are logged in on to the system. In addition to login names finfer utility supplies full name information, information about the device in which person's terminal is connected to, how recently the user typed something on the keyboard, when the user logged in, where the user is located.If the user is logged in over a network, name of the remote system is shown. Usage: $finger $finger username - to get information about specific user locate command is used to finhe location of a file in the database.There are many commands and one among it is the locate command. Usage: locate command-name locate command is based on a database called as slocate database that needs to be set before the locate command is run. slocate database can be updated frequently from crontab. slocate -u - setsup the slocate database updatedb - updates the database Sample Question : You located a file created in /home successfully by using the slocate command. You found that the slocate command could locate that file even after deletion. What could be the possible solution to stop listing deleted files? (Choose all that apply.) A. Run updatedb to update the database. B. Run slocate -u to update the database. C. Use the locate command instead of slocate. D. Delete the /var/lib/slocate/slocate.db file because it buffers all search results. E. Reboot the system so that it will update the kernel memory because the kernel stores all results in the memory. Answer: A, B fsck command is the file system diagnostic command. It is used to check the integrity of file systems.fsck checks all the file systems listed in /etc/vfstab file.To run the fsck command we need to run the system in single user mode.Running fsck in multi-user mode(normal system operation) may lead to corruption. fsck checks the following : 1) missing files or directories 2) Verifies the file path and symbolic links 3) corruption at hardware level 4) checks for block size fmt Utility formats text very simply. The fmt utility does simple textrmatting by attempting to make all nonblank lines nearly the same length. Syntax : fmt [option] [file-list] where, file-list - fmt utility reads the files in the file-list and sends a formatted version of their contents to standard output.If we don't specify filename or if we specify a filename of hyphen(-), fmt reads from standard input. A list of option are given below: --split-only -s - Splits long line but doesnot fill short lines --tagged-paragraph -t - Indents all but the first line of each paragraph --uniform-spacing -u - Changes the formatted output so that once SPACE appears between words and two SPACES appear between sentences. --width=n -w n - Changes the output line width to n characters.Without this optio,fmt keeps output lines close to 75 characters wide.We can also specify this option as -n How does fmt uility work? fmt utility works by moving NEWLINE characters. The indention of lines, as well as spacing between words is left intact. Where do we use fmt? This utility is often used to format xt while we are using an editor,such as vim.For example when we edit using vim positioning cursor at the top of a paragraph and then enterig !}fmt -60 ,this is same as fmt -w 60. How do we undo? By typing u immediately after any formatting we can undo. UNIX Super User - root is a powerful unix user account that can virtually perform any operation including creating users, changing user password, deleting users,deleting OS etc.It is always a good practice to have restriction on granting root user privilege to selected users.Only system administrator should be given root user privilege.Any user having UID(User-id) 0 can be a root. It is mandatory to perform frequent audits to restrict 0 user-id to root user alone(Check the second column in /etc/passwd file). The file /etc/default/login has entries that can be used to restrict root user access.To prevent remote root login i.e preventing a user to login as a root user from a remote system remove the comment in the following line : CONSOLE=/dev/console In the above scenario any user who logs into the system from a remote machine needs to login as a normal user and has to perform a su to obtain root user privileges.If we remove the value of CONSOLE : CONSOLE= We restrict the normal user login as a root user. The user has to do a su to become a root user.These are some of the best security practices recommended as a part of SOX(Sarbanes-Oxley) compliance. What is bootstrapping? Bootstrapping is the process a system follows to load and execute the bootable operating system (OS). Where is the instruction for bootstrap procedure stored? Instructions for bootstrap procedure is stored in boot PROM. What is Yast? Yast helps make system administration easier by providing a single utility for configuring and maintaining Linux systems. Where can we download yast? Refer the link given below :http://oss.oracle.com/projects/yast/files/ What are the Linux Versions supported? Enterprise Linux and RHEL,Suse Enterprise Linux Run state solaris machines DBA tip: Run control levels are different phases in the operation of an operating system. Following are the major run control states in solaris operating system. They are popularly called as run levels. They are usually referred to as rc. Here is a brief listing of different run levels and their description : 0 - At this state system is suitable to be shutdown. For shutting down a system we generally issue init 0 as a root user. Another popular command is shutdown that can be issued as root user. 1,s,S - Popularly called as single user mode. This is the system administrator mode.Only user on the system is superuser/root user and basic kernel functions are enabled in this mode.Only /root and /usr file systems are mounted 2 - Multiple user mode without printer services and NFS services 3 - This is the normal operating state 4 - Undefined 5 - boot -a command. System is shutdown using init 0 command and rebooted to an interactive mode 6- Reboot . System shutdown to inti 0 and started up to 3 (normal state). This can be changed in /etc/inittab file Run states are defined in /etc/inittab file. It points to /sbin/rc scripts. Scripts with K as first alphabet are kill scripts and S as first alphabet are start scripts.