You are on page 1of 31

Linux

Chapter- 1

WHAT IS LINUX?
1. What is UNIX & what is Linux?
UNIX is a general purpose, multiuser, timesharing operating system developed by AT&T at BELL
Labs in C language.
Linux an open-source operating system modeled on UNIX. Linux is an operating system based
on UNIX, and was first introduced by Linus Torvalds commonly used in servers. It is based on the
Linux Kernel, and can run on different hardware platforms.
2. What are the components of Linux distribution? Difference between different Linux
distributions?
Most Linux distributions provide the same basic software:
• GNU utilities and Unix user-land
• BSD utilities
• X.Org
• GNOME, KDE and other GUI components
Differences between distributions are primarily a matter of:
• Packaging and support
• Value-added features
3. Difference between BASH & DOS?
BASH DOS

BASH commands are case sensitive DOS commands are not

/ character is a directory separator / serves as a command argument

\ acts as an escape character \ is the directory separator

BASH follows no naming convention DOS follows a convention in naming


files, which is 8 character file name
followed by a dot and 3 character for
the extension

4. List the difference between Command Line Interface & Graphical User Interface.
CLI is short for Command Line Interface. This interface allows user to type declarative commands
to instruct the computer to perform operations. CLI offers an advantage in that there is greater
flexibility
GUI, or Graphical User Interface, makes use of images and icons that users click and manipulate
as a way of communicating with the computer. Instead of having to remember and type
commands, the use of graphical elements makes it easier to interact with the system, as well as
adding more attraction through images, icons and colors.
1. In the market lot of Linux’s are there. What is the difference between them?
Differences between distributions are primarily a matter of:
• Packaging functions
• Commercial support
• Automatic Updating
• Value-added features
2. What are all UNIX design principles?
 Everything is a file
 Small single-purpose programs
 Ability to pipe small programs together to accomplish more complex tasks
 Each program do one thing well
 Output of every program will become the input of the other.
 Don't hesitate to throw away the clumsy parts of the software or operating system and rebuild
them kernel make minimum policy decisions
 All configuration data stored in ASCII
3. What is VPN? Elaborate all about your understanding?
VPN is Virtual Private Network.
VPN is a network that is constructed by using public wires — usually the Internet — to connect to
a private network, such as a company's internal network. There are a number of systems that
enable you to create networks using the Internet as the medium for transporting data. These
systems use encryption and other security mechanisms to ensure that only authorized users can
access the network and that the data cannot be intercepted. It is also an excellent option for
remote workers and organizations with global offices and partners to share data in a private
manner.
One of the most common types of VPNs used by businesses is called a Virtual Private Dial-up
Network (VPDN). A VPDN is a user-to-LAN connection, where remote users need to connect to
the company LAN. Another type of VPN is commonly called a site-to-site VPN. Here the
company would invest in dedicated hardware to connect multiple sites to their LAN though a
public network, usually the Internet.
4. What is DNS server? Explain.
Domain Name System an Internet service that translates domain names into IP addresses.
Because domain names are alphabetic, they're easier to remember. The Internet however, is
really based on IP addresses. Every time you use a domain name, therefore, a DNS service must
translate the name into the corresponding IP address. For example, the domain name
www.example.com might translate to 198.105.232.4.
5. To display the default gateway configured on the machine.
 ip route show | grep 'default'
 netstat -rn
6. Name the file that displays currently configured DNS server.
/etc/hosts: localhost IP address
/etc/resolv.conf: DNS server configuration file
7. What is the process of ‘init’ in Linux OS?
When the kernel finishes its loading process, it loads and passes control to some initial process,
usually the program init. The init process goes through its initialization procedures, part of which
is to enter the currently defined run-level.
In Unix-based computer operating systems, init (short for initialization) is the first process started
during booting of the computer system. Init is a daemon process that continues running until the
system is shut down. It is the direct or indirect ancestor of all other processes and automatically
adopts all orphaned processes.
8. Mention the types of Linux installation. Typically how do we install Linux on a desktop or a
laptop?
Linux can be installed in two ways
 Through CD-ROM containing the Linux image file
 Through Server(installing through network)
9. What is a server? What are the different types of servers available in present day market,
mention some of their features?
A server is a computer or device on a network that manages network resources and provides
data to other computers. It may serve data to systems on a local area network (LAN) or a wide
area network (WAN) over the Internet.
 File server: a computer and storage device dedicated to storing files. Any user on the
network can store files on the server.
 Print server: a computer that manages one or more printers
 Network server: a computer that manages network traffic.
 Database server: a computer system that processes database queries.
 Mail Server: it move and store mail over corporate networks (via LANs and WANs) and
across the Internet.
 Server Platforms: a platform underlying hardware or software for a system and is thus the
engine that drives the server, operating system.
 Web Server: Web server serves static content to a Web browser by loading a file from a disk
and serving it across the network to a user's Web browser.
 Application Server: it occupies a large chunk of computing territory between database
servers and the end user, and they often connect the two.
 Real-Time Communication Server: formerly known as chat servers or IRC Servers, and still
sometimes referred to as instant messaging (IM) servers, enable large numbers users to
exchange information near instantaneously.
 FTP Server: File Transfer Protocol makes it possible to move one or more files securely
between computers while providing file security and organization as well as transfer control.
 Collaboration Server: Collaboration software designed to enable users to collaborate,
regardless of location, via the Internet or a corporate intranet and to work together in a virtual
atmosphere.
 List Server: List servers offer a way to better manage mailing lists, whether they may be
interactive discussions open to the public or one-way lists that deliver announcements,
newsletters or advertising.
 Telnet Server: A Telnet server enables users to log on to a host computer and perform tasks
as if they're working on the remote computer itself.
 Virtual Server: Datacenter.
10. What is terminal in Linux OS? Command that gives us information on terminal we are using.
A terminal window, also referred to as a terminal emulator, is a text-only window in a graphical
user interface (GUI) that emulates a console. Command that gives us information on terminal we
are using is Tty - TTY is used to describe a terminal session or line. Displays a process or which
users are logged in by typing a tty, such as ttyx, where x is any numerical value. (tty1, tty2, tty3…
tty7)
11. What are daemons?
In multitasking computer operating systems, a daemon is a computer program that runs as a
background process, rather than being under the direct control of an interactive user. Daemons
are services that provide several functions that may not be available under the baseoperating
system. Its main task is to listen for service request and at the same time to act onthese
requests. After the service is done, it is then disconnected and waits for further requests.
12. What is a swap space?
A swap space is a certain amount of space used by Linux to temporarily hold some programs
that are running concurrently. This happens when RAM does not have enough memory to holdall
programs that are executing.
13. What is the advantage of open source?
Open source or ‘Free software' refers to the users freedom to run, copy, distribute, study, change
and improve the software. It allows you to distribute your software, including source codes freely
to anyone who is interested. People would then be able to add features and even debug and
correct errors that are in the source code. They can even make it run better, and then redistribute
these enhanced source code freely again. This eventually benefits everyone in the community.
14. What are the basic components of Linux?
Kernel
Shells and GUIs
System utilities
Application program
15. How do you open a command prompt when issuing a command?
To open the default shell (which is where the command prompt can be found), press Ctrl-Alt-F1.
This will provide a command line interface (CLI) from which you can run commands asneeded.
16. What is typical size for a swap partition under a Linux system?
The preferred size for a swap partition is twice the amount of physical memory available on the
system. If this is not possible, then the minimum size should be the same as the amount of
memory installed.
17. In Linux, what names are assigned to the different serial ports?
Serial ports are identified as /dev/ttyS0 to /dev/ttyS7. These are the equivalent names of COM1to
COM8 in Windows.
18. What is the maximum length for a filename under Linux?
Any filename can have a maximum of 255 characters. This limit does not include the pathname,
so therefore the entire pathname and filename could well exceed 255 characters.

The Linux kernel version is designated by a major number, minor number, and patch level. For
example,2.2.17 has major number 2, minor number 2, and patch level 17. Many Linux distributors add
an additional component, the EXTRAVERSION. Linux kernels with an even minor number (e.g. 1.2.x,
2.0.x, 2.2.x, 2.4.x) are considered stable production kernels. Only bug fixes and isolated features, such
as new drivers, are added to the stable kernel tree. Linux kernels with an odd minor number (e.g. 1.1.x,
2.1.x, 2.3.x) are development kernels, and should not be used on production systems.
Chapter 2

MULTI-USER CONCEPTS

1. What is multi-user & multiple users?


On Multi-user system such as Linux many different users can be logged into the system
simultaneously. Each user may be running different processes, each under the security context of
that user. The key here is simultaneous execution of multiple processes, each within its own
distinct user context.
On Multiple user operating systems only one user can be logged into the system at a time.
Windows NT for example does have a concept of users, and may even associate different
permissions and rights with the various users.
2. Who is root user? What are all the things he can do?
Root user has special access rights and privileges on the system. The root account is like a
systems administrator account, and allows you full control of the system. It is the default account
every time you install Linux. Root user can do:
 change to any directory
 read and write to files regardless of the permissions set on those files
 install software and make it available system wide
 modify device settings
 modify the network configuration
 change the time on the system
 add users to the system
 assume identity of any user on the system
3. What are the various ways of connecting to UNIX servers?
Serial terminals
• getty(/sbin/getty; /sbin/agetty; /sbin/mingetty)
Virtual consoles
• mingetty
Graphical logins
• xdm, gdm, kdm.
Network logins
• telnet, rlogin, rsh, ssh
• login (/bin/login)
4. How to assume identity of another user?
By su– command ($su [user])
5. What is the command to see all users logged onto the workstation?
 users
• who
• w
6. How to find out information about a visitor/user logged into the workstation?
 Finger
7. As a normal user if I issue simple SU command what will happen?
SU (substitute user) commandno assumes you want to switch to roottemporarily.
8. What is the difference between SU & SU –l?
SU: switch to another user account (with substituted UID and GID values)
SU – l: will make the new shell a login shell (process the shell initialization files and set up the
environment as ifan actual login has occurred)
9. What does SU -c command do? How to use it?
SU –c:run a single command as the new user.
10. Give all the commands which will give info about you? And explain in detail about those?
• Id - Prints real and effective user and group IDs.
• Whoami - prints the effective user ID.
11. Give all commands with explanation that will help to find out who else are logged into the
UNIX server?
• users
• who
• w
• finger
12. What is a kernel? How to check the kernel version?
The Linux Kernel is a low-level systems software whose main role is to manage
hardwareresources for the user. It is also used to provide an interface for user-level interaction.
uname –a command gives the kernel version.
13. What are environment variables?
Environmental variables are variables that are defined for the current shell and are inherited by
any child shells or processes. Environmental variables are used to pass information into
processes that are spawned from the shell.
When interacting with your server through a shell session, there are many pieces of information
that your shell compiles to determine its behavior and access to resources. Some of these
settings are contained within configuration settings and others are determined by user input.One
way that the shell keeps track of all of these settings and details is through an area it maintains
called the environment. The environment is an area that the shell builds every time that it starts a
session that contains variables that define system properties.
14. How to find out what OS we are using with OS version info?
$ uname –o
$ lsb_release -a
$ cat /etc/lsb-release
$ cat /etc/issue.net
15. How to find out whether the operating system is 32bit or 64bit?
$ uname -m
$ arch
$ uname -a
i686 signifies that the operating system is 32 bit, and x86_64 means that the OS is 64 bit.
16. How to check hostname of the server?
#hostname
#hostname –fqd
17. How to check domain name of the server?
#hostname –s
18. How to verify the ip-address of UNIX servers?
#hostname –d
#ifconfig
19. How to check the ip-address of windows machines?
#ipconfig
20. What are all the ways to get more info or help about UNIX commands?
man[section] [command name]
info
21. Shortly explain about apropos command.
apropos - searches a set of database files containing short descriptions of system commands for
keywords and displays the result on the standard output. 
22. How to setup private network without using DHCP & hosts file?
Using NEAT command
23. What is the difference commands ‘who’ and ‘whoamI’?
who command shows who is logged on and the login details
$ who -a
system boot 2012-08-07 05:32
run-level 2 2012-08-07 05:32
LOGIN tty4 2012-08-07 05:32 1309 id=4
LOGIN tty1 2012-08-07 05:32 1492 id=1
himanshu + tty7 2012-08-07 05:33 old 1619 (:0)
himanshu + pts/0 2012-08-07 06:47 . 2336 (:0.0)
himanshu + pts/1 2012-08-07 07:58 . 2336 (:0.0)

whoami just prints the effective userid.


$ whoami
Oracle
24. Are Linux commands case sensitive? What are the outputs of cd, CD, & Cd?
Yes Linux commands are case sensitive.
$ cd /d01: the current directory will be changed to d01
$ CD /d01: bash: CD: command not fount
$ Cd /d01: bash: Cd: command not found
25. What are the commands to know user id and the group id?
$id command gives the user id and group id of a user.
26. Command to verify the info about RAM (total, used, free)? In which unit it will give result?
And if I need in MB what is the option to be used?
Free command gives the info about the memory usage of RAM in kilobytes. Free –m is user to
view the details in MB format.
27. How to check the currently configured DNS servers?
 The /etc/resolv.conf configuration file contains information that allows a computer connected to
the Internet to convert alpha-numeric names into the numeric IP addresses that are required for
access to external network resources on the Internet. The process of converting domain names
to IP addresses is called "resolving."The resolv.conf file typically contains the IP addresses of
nameservers (DNS name resolvers) that attempt to translate names into addresses for any node
available on the network.
The man command will search the sections in the following order: 1,8,2,3,4,5,6,7,n.
1. User Commands
2. System Calls
3. Subroutines
4. Devices
5. File Formats
6. Games
7. Miscellaneous
8. System Administration
n. New
Chapter 3

THE LINUXFILESYSTEM

1. What is file system? Explain all your understanding about it?


A file system is the way in which files are named and where they are placed logically for storage
and retrieval. All operating systems have file systems in which files are placed somewhere in a
hierarchical structure. A file is placed in a directory or subdirectory at the desired place in the tree
structure. File systems specify conventions for naming files. These conventions include the
maximum number of characters in a name, which characters can be used, and, in some systems,
how long the file name suffix can be. A file system also includes a format for specifying
the path to a file through the structure of directories.
2. What is the latest file system that is used in windows and Linux?
The latest file system that is been used in windows is NTFS and in Linux its EXT3.
3. Give me some of the Linux file system features?
• singly rooted
• cAsE SensiTiviTY
• long file names
• supports links
• time stamps various file operations (ctime, atime, mtime)
• attributes (ASacdisu)
4. Most of the host-specific files are located in which directory?
/etc contains the Host-specific system configuration files.

5. Explain in detail about your understanding in regards to home directory for users?
A home directory, also called a login directory, is the directory on Unix-like operating systems that
serves as the repository for a user's personal files, directories and programs. It is also the
directory that a user is first in after logging into the system.
A home directory is created automatically for every ordinary user in the directory called /home, a
standard subdirectory of the root directory. The name of a user's home directory is by default
identical to that of the user. It would have an absolute pathname of /home/<username>. An
absolute pathname is the location of a directory or file relative to the root directory, and it always
starts with the root directory (i.e., with a forward slash).
6. What is the command to move between various directories?
$cd<path> OR dir<name>is the command to move between various directories.
7. While navigating between directories we can navigate in two ways. What are those and
explain in detail?
Two ways of navigation is Absolute Addressing and Relative Addressing.
An absolute path always begins with a / and describes allocation from the top, or root, of the file
system like /home/oracle/bin. A relative path never begins with a /, and instead describes a
location from, or relative to, the current directory. If the current directory is /usr/and if we type cd
local/binour current directory will be changed to/usr/local/bin/.
8. Various ways to move back to your home directory?
cd
cd ~
cd $HOME
cd ~username
cd ~/
9. Command to go back to last working directory?
cd .. , cd –
10. What indicates present directory and what indicates parent directory?
‘.’ Indicates the current directory
‘../’ indicates the perent directory
11. Command to go to another user’s home directory?
$ cd
$ cd /home/<username>/
12. Command to find out the directory you are in?
$pwd
13. How to view the content of the directory?
Ls command is used to list the contents of a directory.
14. How to view hidden files in a directory?
ls –a command is used to view the hidden files in a directory.All the files and directories that have
a ‘.’(Period) in front of them are referred to as hidden files.
15. How to list only directories?
$ls -d */
ls -l | grep "^d"
16. How to view long listing of all files? What all info it will provide?
Ls –l command is used to view long listing of all files. Lists the total files in the directory and
subdirectories, the names of the files in the current directory, their permissions, the number of
subdirectories in directories listed, the size of the file, and the date of last modification.

17. How to views the files in a directory and sub-directories in a single command (how to view
files recursively?)
Ls – R command is used to list the file recursively.
18. What is Human readable format? How to view file sizes in human readable format?
A human readable format is a representation of data or information that can be
naturally read by user. Human readable basically means specific representation of that file's
format. ls –h command is used to view file size in human readable format.
19. What is Mount-point in UNIX file system? How to create Mount points?
A mount point is the creation point or the partition level. It is a directory (typically an empty one) in
the currently accessible file system on which an additional file system is mounted. In most Linux
systems, we can use the fdisk utility to create a new mount point and to do other disk
management operations.NFS kernel server is also used to create mount points.
20. Command to find out the hard-disk space utilization at mount point level? And in which
unit?
The df / command shows disk utilization at mount point level. By default, the Linux du command
displays sizes in 1 kilobyte blocks.
21. What is the command that shows total disk space usage? Command that shows the disk
space usage of a user’s home directory?
The du command shows the estimated disk space used by files and directories. Command that
shows the disk space usage of a user’s home directory is:
$ du /home/<username>/
22. Command that shows the disk usage having the output in human readable format.
$ df–h command shows the disk usage in human readable format.
23. Which command is used to find out hard-disk space utilization in units of MB?
$ df–M command shows the hard-disk space utilization in the blocks of1MB.
24. Command to check the space used in a directory?
The du command shows how much space each file system is using on the disk and where it is
mounted.
25. How to verify the space occupied by all the files in a directory excluding sub-directories?
$ du –S command gives the space occupied by all the files in a directory excluding sub-
directories.
26. Space occupied by all the files in a directory including sub-directories how to verify?
$ du–a command gives the space occupied by all the files in a directory excluding sub-
directories.
27. What is ‘quota’ in Linux OS?
A disk quota is a limit set by a system administrator to control disk usage among users that
restricts certain aspects of file system usage on modern operating systems. The function of using
disk quotas is to allocate limited disk space in a reasonable way.
28. How to check the space allotted for a user?
quota–u: List user quotas
29. How to check the space allotted for a group?
quota–g: List group quotas
30. How to change the ownership of a file?
By using chown command we can change the ownership.
31. As normal user am trying to change the ownership of my files and getting error. Why?
Explain?
Only root user has got the power to change the ownership.
32. How to change the group of a file?
By using chgrp command we can change the group.
33. How to change the owner + group with single command?
$ chown<owner_name>:<group_name><filename>
34. How to change the ownership recursively? (Explain recursive as well)
$ chown –R command is used to change the ownership recursively. Recursive means to change
the permissions on everything in any subdirectories of the directories specified on the command
line
35. Explain the group concept in UNIX file system?
Newly created files will usually be given Group ID ownership based on the current active group of
the person who creates the file, by default the file will be owned by the user's primary group.
 newly created files will be owned by the new group
 users can only change to their own groups
 root user can change to any group
 Each user can be a member of many groups
36. Can a user belong to multiple groups?
Each user can be a member of multiple groups.
37. What is primary group and what is secondary group?
Primary Group: Every user must have one and only primary groups, every task performed by
user i.e. file creation, modification etc, and effective groups for task of user will be primary group.
Primary group also specifies a group that the operating system assigns to files that are created
by the user. Each user must belong to a primary group.
Secondary Group: All groups other than primary group called secondary groups, User can be
member of many secondary group. We assign secondary groups to user, to provide him addition
access. Specifies one or more groups to which a user also belongs. Users can belong to up to 15
secondary groups.
38. Can a user belong to multiple primary groups at the same time?
Every user must have only one primary group.
39. Can a user belong to multiple secondary groups at the same time?
Every user must have one and only primary groups
40. How to switch a secondary group to primary?
$ su - <user_name>
$ chgrp<secondary_group_name>
41. How to view the file permissions? And explain in details about those?
Ls –l gives the file permission information.
drwxrwxr-x 10 oracle dba 4096 Aug 25 09:20 base
-rwxr-xr-x 1 root root 1380 Aug 26 07:50 Tasks.txt
lrwxr-xr-x 1 root root 2968 Jul 10 09:22 oracle.com

File type/user permissions/group permissions/others permission


(d/-/l)/rwx/rwx/rwx
There are 3 types of file types:
D – Directory
- - file
L - Link
Permissions:
r- Read permission- 4
w- Write permission – 2
x- Execute permission - 1
42. Command to change the file permissions?
$ chmod<permission>file_name
43. What are the various types of permissions, with those permissions what we can do?
The various types of permissions are READ, WRITE, EXECUTE. Read permission enables the
user to read a file, Write permission enables a user to write into the file, with Execute permission
a user can run the file.
44. Provide me the numerical equivalence of each permissions.
r- Read permission- 4
w- Write permission – 2
x- Execute permission - 1
45. Give me command which needs to set the file permissions as below in both methods. user-
read, write, execute / group read, ----, execute /others read,----,-----
$ chmod u=rwx,g=rx,o=r file_name
$ chmod 754 file_name
46. Command to modify the file permissions recursively? (Explain recursive)
$ chmod –R command is used to change the file permissions recursively. Recursive option
changes the permission of all the files in the directories recursively.
47. What are the default permissions for a file when it is created?
-rw-rw-rw- / 666
48. What are the default permissions for a directory when it is created?
drwxrwxrwx / 777
49. While creating a file can we grant execute permissions?
No we can’t grand execute permission for a file at the time of its creation.
50. Command to withhold the file permissions for all the files and directories that are going to
be created.
$ umask command defines what permissions to withhold from the default permissions.
51. How to find out the file permissions before those are created?
Using umask command.
52. How to set/alter user password using command line?
passwd command is used to set/alter User password. User’s password are stored in file
/etc/shadow
53. Explain umask command in detail with examples.
On Linux and other Unix-like operating systems, new files are created with a default set
of permissions. Specifically, a new file's permissions may be restricted in a specific way by
applying a permissions "mask" called the umask. The umask command is used to set this mask,
or to show you its current value.
Example:
666 Default File permission.
-002 Umask value
----
664 Initial file permission (rw-rw-r--)
The Root Filesystem
/ The root directory
/bin/ Essential command binaries
/boot/ Static files of the boot loader, kernel, and initial RAM disk
/dev/ Device files
/etc/ Host-specific system configuration
/home/User home directories
/lib/ Essential shared libraries and kernel modules
/media/ Mount point for removable media (LSB addition)
/mnt/ Mount point for mounting a filesystem temporarily
/opt/ Add-on application software packages
/root/ Home directory for the root user
/sbin/ Essential system binaries
/srv/ Data files for system services (LSB addition)
/tmp/ Temporary files
/usr/ Second hierarchy, Non-essential read-only data (see /usr/ breakout for details)
/var/ Variable data files. Includes spool directories and files, administrative
The /usr/ Hierarchy
/usr/bin/ Most user commands
/usr/include/ Header files included by C programs
/usr/lib/ Libraries
/usr/local/ Local hierarchy (empty after main installation)
/usr/sbin/ Non-vital system binaries
/usr/share/ Architecture-independent data
The /var/ Hierarchy
/var/cache/ Application cache data
/var/lib/ Variable state information
/var/local/ Variable data for /usr/local
/var/lock/ Lock files
/var/log/ Log files and directories
/var/opt/ Variable data for /opt
/var/run/ Data relevant to running processes
/var/spool/ Application spool data
/var/tmp/ Temporary files preserved between system reboots

Chapter 4

MANIPULATING FILES

1. How to create a directory?


The mkdir command creates directories.
2. Whenever you create a directory what is default permissions? When unmask is 0000?
The default permissions for a directory with 0000 umask is 777.
3. When unmask is 0000, I want to create a directory with permissions rwx-rw-r—, what is the
command? In other words while creating the directory want to set the permissions.
rwx – 7=> umask = 0, rw – 6 => umask = 1, r – 4 => umask = 3. Total umask = 013.
777 – 013 = 764
$ mkdir –m 764 <directory_name>
4. With a single command I want to create parent directory + sub directory then what is the
command?
$ mkdir –P <parent-directory_name>/<sub-directory1_name>/<sub-directory2_name>
5. Command to remove the empty directory?
$ rmdir –p <directory_name>
6. Am trying to remove directory with rmdir, but getting the message the directory is not
empty? What needs to be done?
$ rmdir –R <directory_name>
7. How to copy files? Give me the syntax and explain?
cp[options] source destination
cp[options] source1 source2 [...] destination_directory.
Cpcommand copies file and directories from source to destination. Multiple files can be copied
from many sources to a single destination. A directory can be copied recursively to a particular
destination.
8. Which command is used to rename a file?
$ mv command is used to rename the file.
9. How to copy directory and sub directory with single command?
$ cp –r <source><destination>
10. Command to move the files, syntax + explanation?
The mvcommand will move or rename files or directories, or can move multiple sources (files
anddirectories) to a destination directory. The basic syntax of the mvcommand is:
mv[options] source destination
mv[options] source1 source2 [...] destination
11. Can I move multiple files with single command?
Yes we can move multiple files with single mv command.
12. What is the difference between copy and move? And which is faster?
mv is used to move or rename the files but it will delete the original file while moving.
cp command is used to copy the files but like mv it's not delete the original file, the original file
remain as it is.
13. While copying the files if the file to be copied is latest when compared with file to be
overwritten then only want to copy? What is the command?
$ cp –u<source><destination>
14. Command to remove the files.
$ rm[options] file_name
15. Using rm command how to remove directory with files and subdirectories.
$ rm-rf<file_name>
16. One of the commands to create a file?
$ touch <file_name>
17. How to identify hidden files in Linux OS?
All the files and directories that have a ‘.’ (Period) in front of their name are referred to as hidden
files
18. If the file was already there and if you issue touch followed by filename then what will
happen?
It will update the access (atime) and modification (mtime) times of each specified file to the
current time or to a specified time.
19. Right now the file access time is 10:00AM and you need to modify as 8:00AM. How to do
that?
$ touch -a<file_name>
20. Explain links?
A link is an entry in the file system which connects a filename to the actual bytes of data on
the disk. More than one filename can "link" to the same data.
ln [OPTION]... TARGET [...] [LINKNAME [...]]
ln creates a link to file TARGET with the name LINKNAME. If LINKNAME is omitted, a link
to TARGET is created in the current directory, using the name of TARGET as the LINKNAME.
21. How to create hard link? Explain all the characteristics?
Hard links are created by the command ‘ln’. A file comprises an inode and at least one data
block. Whenever a hard link is created the addition of another name to a directory referencing
that file’s inode is made.
Characteristics:
 Can’t span file-systems
 Can’t create hard link to non-existing files
 Can’t reference directories
 Do not occupy storage space(I,e. blocks)
22. How to create symbolic link? Explain all the characteristics?
Symbolic links are really a reference to another file or directories, not an inode. If the path doesn’t
exist and name that doesn’t not exists, the link is said to be dangling. We must use -s option to
create a slink.
Characteristics:
 Can span file-systems
 Can create hard link to non-existing files
 Can reference directories
 occupy storage space(ie. blocks)
23. By using which type of link we can link directories?
Symbolic links are used to link directories.
24. If a file doesn’t have any extension then how to verify what type of file it is?
By using file command.
25. In what all the ways we can see the content of a file? Explain all the commands?
Cat: it dumps a file to STDOUT, is convenient for viewing small files or working with pipes.
More: displays a file one screen at a time. It loads an entire file before it is displayed, so it is often
unsuitable for a large file.
Less: displays file one screen at a time. Less does not need to load an entire file to begin
displaying it, and therefore works well with large file either.
26. If I want to see the first 5lines of a file then what is the command?
$ head –n 5 <filename>
27. If I want to see last 10lines of a file then what is the command?
$ tail<filename>
28. Explain tail –f command?
Tail –f command is used to continuously display the end of file in real time as contents are
appended or updated to file. Ctrl+C key combination is used to stop this command.
29. Command to search for text data inside binary file?
Strings command is used to scan a binary file for readable characters.
30. How to search for a file in the file system and give me the syntax? Explain in detail.
Find command searches the file system and perform action on files that matches the search.
Find path[.....][Expression]: where to search, what to search, what to do with the results.
31. In /home directory find all the files with extension *.txt and owner is venu.
$ find /home –name ‘*.txt’ –type f –user venu
32. How to search for all files that are modified within last 30min?
$ find / -mmin -30 -ls
33. How to search for all files that are modified 1hour back and within 2hours?
$ find . –mmin +60-120 -ls
34. How to search for all files in current directory that are modified with in 1day?
$ find . –ctime -1 -ls
35. Search for all files owned by venal and change the ownership to venu.
$ find / -user venkat exec chown venu {} \;
36. How to search for all files size greater then 1GB?
$ find /home –type f –size +1G
37. Purpose of locate command? Explain in detail.
Locate command searches the files and directories in the index created by the database, it does
not search the file system in the real time. This approach provides very fast searching.
$ locate option search string
38. What is meant by echo in Linux OS? What would be the output of echo $PATH?
Echo is a command in Unix and Unix-like operating systems that places a string on the computer
terminal. It is a built-in command typically used in shell scripts and batch files to output status text
to the screen or a file. The output of echo $PATH display the current path settings under Linux.
39. When I use the find command and search it is displaying the file and when I use locate it is
not. What could be the problem?
Indexing is instantiated at night. Hence updated file after indexing cannot be found through locate
command. Whereas find command searches through the file system to locate the file.
40. How to check no of characters in a file?
$ wc –c <filename>
41. How to check no of lines in a file?
$ wc –l <filename>
42. How to check the length of longest line in a file?
$ wc L <filename>
43. Give the syntaxes for file, tee, & try commands.
File: The file command is used to determine a file's file type.
$ file –option
Tee: Reads from standard input, and writes to standard output and to files
$ tee [OPTION]... [FILE]
44. What do we use diff command for?
diff analyzes two files and prints the lines that are different. Essentially, it outputs a set of
instructions for how to change one file in order to make it identical to the second file.
45. What is lp/lpr used for?
The lp/lpr command is used to submit print jobs in Linux.
46. Explain the following commands Lpstat/lpq, cancel/lpr, &pr with syntax.
Lpstat displays status information about the current classes, jobs, and printers. When run with no
arguments, lpstat will list jobs queued by the current user.
$ lpstat [option]
Cancel command cancels a print job on System V Unix. When specifying printers, printer names
are not case-sensitive.
$ cancel [option]
Pr command formats a file to make it look better when printed.
$ pr [OPTION]... [FILE]...
47. What is the command to view the contents of a text file?
The contents of a text file can be viewed by using cat, more and less commands.
48. Syntax for ‘pg’ command.
pg is a pager: it allows you to view text files one page at a time. After each page, a prompt is
displayed. The user may then either press the newline key to view the next page or one of the
keys described below.pg acts like cat but precedes each file with its name if there is more than
one.If input comes from a pipe, pg stores the data in a buffer file while reading to make navigation
possible.
pg [-number] [-p string] [-cefnrs] [+line] [+/pattern/] [file...]
49. Briefly explain ‘head’ & ‘tail’ commands
head:
By default the head command prints the first 10 lines of a file, as shown in this head command
Ex: head file1
If you want to print only 5 lines:
head –n 5 file1
tail:
By default the Linux tail command also prints ten lines of a file, but it prints the last 10 lines, as shown
in this tail command example:
tail file1
Like the head command, the tail command also lets you specify a number other than 10 using the –n
option.
tail -25 file1

Chapter 5

TEXT PROCESSING

1. Command to search for a string inside a file without opening it? Give me syntax and
explanation?
Grep command is used to search for a string inside a file without opening it.
grep[options] [[-e] pattern] filename [...]
The grepcommand in Linux searches a file or files for a pattern and by default prints the lines
containingmatches
2. While searching inside I want the searched line with the number what is the option?
$ grep-n pattern filename
3. While searching in the file I want before 5lines and after 5lines with match?
$ grep–c 5 pattern filename
4. While searching in a file I want all that are not matched?
$ grep -v pattern filename
5. Command to replace all lower case letters to upper case?
$ cat filename | tr a-z A-Z
6. How to sort the lines in a file?
$ sort [option] filename
7. When sorting numbers I want to sort based on their actual value, how to do that?
$ sort –n filename
8. How to eliminate duplicates while sorting?
$ uniq filename
9. What will ‘fgrep’ & ‘egrep’ commands do?
Grep: "Global Regular Expressions Print". grep is a program which scans a specified file or files
line by line, returning lines that contain a pattern. A pattern is an expression that specifies a set of
strings by interpreting characters as meta-characters.
Egrep: "Extended Global Regular Expressions Print". The 'E' in egrep means treat the pattern as
a regular expression. egrep is the same as grep –E, which treats +, ?, |, (, and ) as meta-
characters. In basic regular expressions (with grep), the meta-characters ?, +, {, |, (, and ) lose
their special meaning. If you want grep to treat these characters as meta-characters, escape
them \?, \+, \{, \|, \(, and \).
Fgrep: "Fixed-string Global Regular Expressions Print". fgrep is same as grep –F, is fixed or fast
grep and behaves as grep but does NOT recognize any regular expression meta-characters as
being special. The search will complete faster because it only processes a simple string rather
than a complex pattern.
Pgrep: "Process-ID Global Regular Expressions Print". pgrep looks through the currently running
processes and lists the process IDs which matches the selection criteria to stdout. pgrep is handy
when all you want to know is the process id integer of a process.
10. Command to extract the column inside a file?
$ sort –t : -k column_Number filename
11. Using which command can we replace all occurrences of the letter ‘e’ with then letter ‘y’ in
the word ‘’mail queue ’’.
$ sed s/e/y/g “mail queue”
12. What is sed command used for?
Sed is a streaming editor, which means that sed performs edits on a stream of text. The stream
may come from a file or a pipe. It is particularly useful for editing text from a pipe. The sed
command only makes one pass over the input (file or text stream) and therefore is very efficient.
13. How to extract column 5,6 from a file with delimiter is ‘:’?
$ sort –t : -k 5,6 filename
14. How to merge two files horizontally?
$ paste file1 file2
15. What is parsing?
Parsing is the process of analyzing a string of symbols, either in natural language or in computer
languages, according to the rules of a formal grammar. It is also breaking a data block into
smaller chunks by following a set of rules, so that it can be more easily interpreted, managed, or
transmitted by a computer.

16. What is ‘awk’?


awk is a powerful pattern scanning programming language with features found in other command
line utilities such as grep, sed and cut. It also supports a rich set of math operators, conditionals,
variables and file IO operators. awk is commonly used in system shell scripts to process
configuration data or command output.
17. Syntax for ‘cut’ command.
$ cut [options] [filename] [...]
18. What does cut -d command do?
Cut command cuts sections of text from files, or STDIN, and neatly pastes them together to
STDOUT. It is most useful with files or input that contain information arranged using tabs or some
other delimiting character
$ Cut –d: delimiter: use this delimiter instead of the default

Chapter 6
SHELL BASICS
1. What is shell and what is its advantage?
Shell is the layer between the user and the operating system.Shell is a user program or its
environment provided for user interaction. Shell is a command language interpreter that executes
commands read from the standard input device (keyboard) or from a file.Shell is not part of
system kernel, but uses the system kernel to execute programs, create files, access to file
system, scriptability for task automation, program launching, process control interface
Advantages:
 Easy to use
 Quick start and interactive debugging
 Time saving
 System admin task automation
 Shell scripts can execute without any additional efforts on nearby any modern Unix/ Linux/
BSD/ Mac OS as they are written an interrupter language.
2. Explain standard input, standard output & standard error? Represented by what numbers
and what Symbols?
STDIN (standard in) represented by 0: symbol <: where the program gets input. This is usually
the keyboard.
STDOUT (standard out) represented by 1: symbol >: where the program sends output. This is
usually the terminal.
STDERR (standard error) represented by 2: symbol 2>: where the program sends
errormessages. This is usually the terminal.
3. Command cat xyz.txt > abc.txt what will be the result if abc.txt is already there or if it is not
there?
If adc.txt exists: contents of abc.txt get over written by content of xyz.txt
If adc.txt does not exists: new file will be created by the name abc.txt
4. What is the result of cat xyz.txt 2> abc.txt?
It copies the error message from xyz.txt to abc.txt
5. Command cat xyz.txt >> abc.txt what will be the result if abc.txt is already there or if it is not
there?
If adc.txt exists: content of xyz.txt gets appended with abc.txt
If adc.txt does not exists: file will be created and the content will be written in to abc.txt
6. How to capture standard error and standard output in a single file?
By using <input file>&><output file>
7. Explain piping? Symbol for piping? Give me one example?
Piping allows the STDOUT from one program (on the left of the pipe) to become the STDIN of
another (on the right of the pipe)
8. List all wild card characters with explanation?
A wildcard pattern is a string that contains one of the characters ‘?’, ‘*’or ‘[]’
? any single character
* anything
[...] classes and ranges
9. How to suppressor ignore the special meaning of wild card characters?
By inserting the forward slash b/w special characters we can suppressor or ignore the special
meaning of wild card characters
10. What is the purpose {}? Explain with examples?
Brace expansion allows the generation of arbitrary strings in the following form where the
preamble and postamble are optional
[preamble]{string1,string2}[postamble]
$ echo t{able,op,ennis}
table top tennis
11. What is shell variable? And what is environment variable? What are the key environment
files?
Shell variables are only available to the current invocation of the shell;
Environment variables become properties of the system and transcend shell invocation.
12. Command to find out all the available environment variables?
env command find out all the available environment variables.
13. Purpose of PATH environment variable?
$PATH - Executable search path: contains a list of directories the shell will look in for a program
when it is called
14. How to execute the file if the file directory is not part of PATH environment variable?
If the file is not a part of PATH environment, the file can be retrieved through absolute method by
giving full path or relative method by using symbolic notations.

Chapter 8
ARCHIVING AND COMPRESSION
1. Command to create tar file. Syntax and explanation?
$ tar -cf<filename>.tar <file location>
"tar" stands for tape archive. It is an archiving file format.
c: Create a new archive.
f: Use archive file (or device) ARCHIVE.
2. Command to extract tar file. Syntax and explanation?
$ tar -xf<filename>.tar
x: Extract files from an archive.

3. Create a directory named test, create few files ex: test1.txt, test2.txt., inside the directory.,
Tar the directory to a single Tar file.
$ mkdir test
$ touch test/file{1,2,3,4,5}
$ tar -cf testdir.tar testdir/
4. Command to see the content of the tar file without extracting it?
$ tar -tf<filename>.tarlist the contents of an archive without extracting.
5. Advantage of cpio command?
 manipulates .cpio files
 used as the basis for RPM packages
 doesn't recurse subdirectories, must be passed list of dirs
 more robust than tar when media errors encountered

6. How to create a cpio file? Give its Syntax.


$ cpio -o: output mode–create a new cpio archive. When creating an archive, the cpio command
expects to be given a list of files and directories to backup via STDIN and will output an archive
via STDOUT. Be sure to redirect the output to a file.
7. How to extract a cpio file? Syntax.
$ cpio-i: input mode–extract from a cpio archive. When extracting an archive, the cpio command
expects to be given an archive on STDIN. Use the –doption to create a directory tree on
extraction. In all cases adding the -v option provides verbose output.
8. How to create gzip file? Syntax + explanation?
gzipis an improvement over compress and gets higher compression ratios. It is fairly widely used
to distribute and archive files.
gzip[options] filename
The gzipcommand has the ability to adjust the compression ratio. Use the -9 option for highest
(andslowest) compression, or use -1 for fastest (and lowest) compression.
9. How to extract gzip file? Syntax + explanation?
gunzip filename
10. Can we create a gzip file for a directory?
No. we can create gzip for only one file.
11. What do we use ‘cmp’ command for?
To compare two files byte by byte.
Syntax:
cmp [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]

12. How to use gzip compression in tar file?


By adding –z option to tar command we can enable gzip compression and decompression.
Creating a tar file: $ tar -zcffilename.tar.gz <destination>
Extracting a tar file:$ tar -zxf filename.tar.gz
13. Command to list uncompressed files to screen, leaving files compressed on disk

14. How to create and extract bzip file?


To create bzip file:bzip[options] filename
To extract bzip file:bunzip filename
15. How to use bzip compression in tar file?
Adding the -j option to tar enables automatic bzip2 compression and decompression:
$ tar -jcf<filename><location>
The file can be extracted in the same manner:
$ tar -jxf<filename>

Chapter 9

Text Editing

1. In Vi what are all the various modes available and how to switch between them?

a. Insert mode –

By pressing i, we can insert words into the text file.

b. Command mode –

w - save file to the disk

q - quit (exit) if all changes have been made

wq - save and exit

w! - save the file even if it is read only

q! – exit even if changes have not been saved

wq! – save and exit even if the file is read only

2. Basic cursor movement commands?

h – move the cursor to the left

j - move the cursor down one line

k - move the cursor up one line

l - move the cursor to the right

3. How to delete a line as well delete a character?

x – deletes a character

dd – deletes the line under the cursor

4. Various ways of saving and exiting from a file after modification?

w - save file to the disk

q - quit (exit) if all changes have been made

wq - save and exit

w! - save the file even if it is read only

q! – exit even if changes have not been saved

wq! – save and exit even if the file is read only


5. How to search in a file in forward direction? Also repeat the search?

/ filename

n – to repeat the last command

6. In a file search for venkat venu and replace it with venu madhav for all the occurrences with
single command?

%s /venkat venu/ venu madhav/g

7. How search and replace the string between 10 and 30lines?

10, 30s/venkat venu/ venu madhav/g

8. How to copy a 5lines and paste it?

To copy- 5yy

And to paste – p

(Lower case p pastes after the cursor position and upper case P pastes before.)

Chapter 10

Command Shells

1. What is the purpose of the shell? And how to identify the current shell?

In Unix, the shell is a program that interprets commands and acts as an intermediary between the
user and the inner workings of the operating system. Providing a command-line interface (i.e., the shell
prompt or command prompt), the shell is analogous to DOS and serves a purpose similar to graphical
interfaces like Windows, Mac OS X, and the X Window System.

Nearly every UNIX system has these two shells installed i.e. sh and csh, but may also have several
others: bash, ksh, tcsh, and zsh.

To identify a shell that is currently in use we type this command:

$ echo $SHELL or

$ ps -f

2. How to switch from one shell to another shell?

Use the chsh command to change your login shell.

When prompted, specify /bin/tcsh as your new shell:

$ chsh

Changing shell for guru.

Password: work (Enter)

New shell [/bin/bash]: /bin/tcsh


Shell changed.

3. Whenever the user logs in what are all the files that are automatically executed?

.bash_profile

/etc/environment
/etc/profile
/etc/cshrc
/etc/login

4. When using bourne again shell how to view the history of commands?

“History” command gives the history of commands.

5. How to customize the prompt? Give me some options as well?

After user login to the systems user environment variables initialized from various files like:

 global system files: /etc/profile or /etc/bashrc


 user files: ~/.bash_profile , ~/.bash_login , ~/.profile , ~/.bashrc or ~/.bash_logout

Bash prompt can be customized by changing the values of bash PS1, PS2, PS3, PS4 variables.

Chapter 11

Introduction to Shell Scripting

1. In shell scripting how to display a message?

“echo” command is used to display messages.

$ echo -e "foo\nbar\nbaz"

foo

bar

baz

$ echo -e "foo\tbar\tbaz"

foo bar baz

$ echo -e "foo\vbar\vbaz"

foo

bar

baz

$ echo -e "foo\nbar\rbaz"

foo

baz
2. How to accept values into variables?

#!/bin/bash

if [ -z "$TEST_DIR" ]

then

echo "TEST_DIR was not set, please enter the path: "

read input_variable

export TEST_DIR=$input_variable

fi

3. Give me all positional parameters details?

Special built-in shell variables pass arguments from the command line into a shell script.

File: variable.sh

#!/bin/sh

echo "The script name is: $0"

echo "The first argument passed is: $1"

echo "The second argument passed is: $2"

echo "The number of arguments passed is: $#"

echo "The list of arguments passed is: $@"

Output:

$ ./variable.sh foo bar baz

The script name is: variable.sh

The first argument passed is: foo

The second argument passed is: bar

The number of arguments passed is: 3

The list of arguments passed is: foo bar baz

Checking the Number of Positional Parameters

An example of using the $# variable would be to verify that a script is being called with the correct
number of parameters.

This could be accomplished with simple code such as:

if [ $# -ne 3 ]; then

echo "Invalid usage - Please call me with 3 args"

fi

4. Give me the syntax for if – then - elif – else – fi condition?


if - then

In this example code block, the echo command is only run if the variable $X is equal to the integer 5:

if [ $X -eq 5 ]; then

echo "Got to 5"

fi

if - then - else

if - then constructs can also include an else clause. Note that with this structure one or the other

statement will be executed, but never both:

if [ $X -eq 5 ]; then

echo "We got to 5"

else

echo "We are not at 5"

fi

if - then - else - if

The addition of an elif clause allows the if - then block to test for several conditions (these are often

called "if-else trees"):

if [ $X -eq 1 ]; then

echo "At 1"

elif [ $X -eq 2 ]; then

echo "At 2"

else

echo "Neither 1 or 2"

fi

5. Give me case and esac syntax?

For complex conditionals, a more readable approach is to use the case construct instead of an if-else

tree (these are often called "switches" by programmers):

case $X in

1)

echo "Got 1";

;;

2)
echo "Got 2";

;;

*)

echo "Got something else";

;;

esac

6. Give me for loop syntax?

$ for FILE in *; do

> mv $FILE $FILE.old

> done

. . . output omitted . . .

7. Give me while condition syntax?

X=0 # Initialize $X

while [ $X -lt 5 ]; do

touch $X.txt

X=$(expr $X + 1)

Done

Chapter 12

Process Management and Job Control

1. What is process?

A process is an executing (running) of a program. In a multitasking operating system, multiple


instances of a single program can be executing simultaneously, and each instance is a separate
process (or processes).

2. Explain me various status of a process?

R - running process

D - uninterruptible sleep (I/O)

S - interruptible sleep (waiting for an event to complete)

Z - zombie, terminated but not reaped by its parent

T- stopped, either by a job control signal or because it is being traced

3. How to identify zombie process?


Using this command you can identify the Zombie processes:

$ ps aux | grep Z

4. Various ways of monitoring processes?

 Using the following commands:

ps, & top

5. How to kill a process?

To kill any processes- You use kill Command. If you want to terminate for example the emacs
process you would look up the process identifier (PID) say 3216, and enter:

$ kill -9 3216

The -9 will ensure "execution".

To kill a Zombie process-

Suppose 2343 is the parent process id of a zombie process.

The SIGCHLD signal will ask the irresponsible parent to reap their children, who are zombies.

$ Kill –s SIGCHLD 2343

6. How to run a command in back ground?

By adding a “&” to the end of a command, you can make it run in the background.

Examples:

command &

script &

command -1 | command -2 –arg1 –arg2 > /path/to/output &

7. How to identify all the jobs that are running in background?

Using ‘jobs’ command, we can list all the jobs that are running in the background.

Ex: $ jobs

[1] Stopped vim

[2]- Running playsound.wav

[3] + Stopped man ps

(+ sign means this process will be foregrounded if you just


type fg without a number)

8. How to bring a command to foreground which is running in background?

“fg”

Ex: $ jobs
[1] Stopped vim

[2]- Running playsound.wav

fg2 would bring playsoundwav process back to the foreground

Chapter 15

Managing Software

1. Command to transfer file from server 1 to server 2 using ftp?


ftp> get filename &

ftp> put filename

get and put commands are used for downloading and uploading files from one server to another server

2. Command to transfer files in binary mode?


After you log in to an ftp site, ftp will print out the file transfer type. In our case, it is binary. Binary mode
transfers the files, bit by bit, as they are on the FTP server. Ascii mode, however, will download the text
directly.
You can type asc or bin to switch between binary and ascii file types.
bin / asc
3. Command to get multiple files from server 2 to server1?
ftp> mget linux*
m stands for multiple
This command would get all files starting with the string "linux".
4. In linux the software is released as which type of file?
RPM package manger
5. How to install the software?
rpm –ivh file.rpm command installs the desired software on linux systems.
6. How to upgrade the software?
rpm –uvh file.rpm command upgrades the required software on linux systems.
7. How to remove the software?
rpm –e file.rpm
8. How to check the software is installed or not?
rpm –qa | grep file.rpm
Chapter 17

Mounting File systems and Managing removable Media

1. How to mount a file system?

a. Become root user

b. Create a mount point for the file system to be mounted, if necessary

#mkdir /mount-point

c. Mount the UFS file system

#mount [-o mount –options] /dev/dsk/ device-name /mount-point

Ex: #mount /dev/dsk/c0t3d0s7 /files1

2. How to view all the available mount points?

$ mount -v

–v displays the list of mounted file systems in verbose mode.

3. If you want to automate mounting then in which file we need to add the entry?

The /etc/fstab file

autofs

• Allows automated mounting of resources on demand


• Automatically unmounts resources when no longer used
• Allows non-privileged users to trigger mounts and unmounts of resources

4. How to unmount a file system?

To unmount a filesystem

#umount /mount-point

To unmount a filesystem forcibly

#umount –f

To verify a file system is unmounted


$ mount | grep unmounted-file-system
0r
# fsck /dev/sdb4
To list by PID all processes that are accessing a filesystem, you can use the command:

$ fuser -m /filesystem/

To stop all the processes those are accessing the file system
#fuser –c –k /mount-point

-k is used to kill

5. Explain in detail about the NFS mounting?

#mount -F nfs [-o mount-options] server:/directory /mount-point

-o specifies the mounting options used for mounting an NFS file system

server:/directory specifies the server’s host name that contains the shared resource, and the path to
the file or directory to mount.

/mount-point specifies the directory on which to mount the file system

Examples:
# mount -F nfs pluto:/export /packages /mnt

# mount -t nfs of50:/stage /mnt/stage

6. How to upgrade an existing ext2 file system to ext3?

Using the tune2fs command with the "-j" flag to turn on journaling.


# tune2fs -j /dev/sdb4
Creating journal inode: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
#
7. How to convert an existing ext3 file system to ext4
Issue the tune2fs command with the following options.
# tune2fs -O extents,uninit_bg,dir_index /dev/sdb4
tune2fs -O extents,uninit_bg,dir_index /dev/sdb4
tune2fs 1.41.12 (17-May-2010)
Please run e2fsck on the filesystem.
#
8. How to see the current swap volumes? Command to disable a swap volume.

# swapon –s

# swapoff command is used to disable a swap volume.

Ex: # swapoff /dev/sdb2

Chapter18

X-Windows

1. As a normal user how to run the graphic programs?


Using X Window (xinit)

2. How to start x-server?

If you wish to start x manually, you can use the command startx, which will launch a gui.

You can also change the default xinit level in your /etc/inittab file.

3. Explain me importance of xhost command?

You can easily connect to other computers and run graphical user interfaces over the
network.

Use xhost on the server system to allow the client system use the display. If the server's IP address is
192.168.20.1, enter the command:

$ xhost + 192.168.20.1

 xhost + hostname: Adds hostname to X server access control list.


 xhost - hostname: Removes hostname from X server access control list.
 xhost + : Turns off access control (all remote hosts will have access to X server)
 xhost - : Turns access control back on.

4. Before running graphic commands in a remote server what are all the steps we need to take
to see the display?

If you would want to use telnet to display graphical applications running on a remote


machine, you first need to give the remote machine access to your display (to your X
server!) using the xhost command, by typing the below command in a terminal window on
your local machine:

Xhost + remote.machine.com

You might also like