Professional Documents
Culture Documents
Linux Q&a3
Linux Q&a3
All devices are represented by files called special files that are located in /dev
directory.
Q: Tell me the steps to remove the swap file?
Firstly disable the swap file by swapoff command.
Remove Swap file entry from /etc/fstab file.
Now remove the swap file by rm command.
Q: What can we do with parted command or utility?
View the existing partition table
Add partitions from free space or additional hard drives
Change the size of existing partitions
Q: - What is inode?
All UNIX files have its description stored in a structure called inode. The inode
contains info about the file-size, its location, time of last access, time of last
modification, permission and so on. Directories are also represented as files and
have an associated inode.
Q: Can we resize the size of a partition?
Yes, we can resize the size of partition by parted command.
#parted /dev/sda
print
To resize the partition, use the resize command followed by the minor number for
the partition, the starting place in megabytes, and the end place in megabytes. For
example:
resize 3 1024 2048
After resizing the partition, use the print command to confirm that the partition has
been resized correctly, is the correct partition type, and is the correct file system
type.
Q: What is LVM?
LVM stands for Logical Volume Manager. LVM, is a storage management solution
that allows administrators to divide hard drive space into physical volumes (PV),
which can then be combined into logical volume groups (VG), which are then
divided into logical volumes (LV) on which the filesystem and mount point are
created.
Q: What are the steps to create LVM?
- Create physical volumes by pvcreate command
#pvcreate /dev/sda2
- Add physical volume to volume group by vgcreate command
#vgcreate VLG0 /dev/sda2
- Create logical volume from volume group by lvcreate command.
#lvcreate -L 1G -n LVM1 VLG0
Now create file system on /dev/sda2 partition by mke2fs command.
#mke2fs -j /dev/VLG0/LVM1
Q: - How we will check free space on drive /dev/sda with parted command?
#parted /dev/sda
print
Q: - What are the process states in Unix?
As a process executes it changes state according to its circumstances. Unix
processes have the following states:
Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.
/var/log/wtmp log file keeps track of all user logins and logouts.
What is the first process that is run when a Linux system starts, and is
responsible for starting all other system processes and services?
The init process is the first process to be run. It is the parent process of all other
Linux system processes, services, and daemons that are needed to run the system.
Which command will you use to bring a process in foreground, which is
running in the background?
The fg command immediately moves the program to the foreground.
An administrator has accidentally killed a core process. What is the result
of this action?
Killing a core process can potentially crash your system because many critical
services rely on these core processes
As a administrator you need to monitor the /var/log/messages file in real
time to resolve the issue? How would you do that?
You can use tail command with -f option. Following command will do the assigned
task
#tail -f /var/log/messages
From the output of ps command how will you determine the ID number of
the parent process of a particular program?
PPID refers to the parent process identification number.
While scanning the /var/log/messages file, you notices an error stating an
authentication failure for root. What could this mean?
Any failed login attempts for root are logged into the /var/log/messages file. It
indicate that some has tried to login as root.
As an administrator you noticed from top command that an unidentified
process is using up all CPU and memory. You suspects that is a user's
process that has run away. How should you fix this ?
The process should be immediately killed before it consumes so many resources
that the server cannot run properly, and therefore crash.
To extract files from an archive, use the -x argument in the tar command.
What init runlevel should be set to shut down and reboot the system?
init runlevel 6 is used to shut down and reboot the system
What command would you use to add the user name vickey?
#useradd vickey
This command will add the user viceky with default options. But this will not be able
to login in system until you set a password for it. To set password use following
command
#passwd vickey
Which runlevel currently not is used ?
Runlevel 4 is not used.
Your company hired a new developer for temporary periods to speed up
the ongoing project. You are tasked to create a new user account which
should be disabled automatically on 5 may 2014. How would you do that?
Use -e option with useradd command. -e option allows you to set the date on which
the user account will be disabled. The date is specified in the format YYYY-MM-DD.
Following command will do the assigned task
#useradd -e 2014-05-05
Which command should you use to change the user information listed
form finger command?
chfn command is used to change the information listed from finger command.
What runlevel does init 6 represent?
Runlevel 6 is used to reboot the system.
You are tasked to delete a user account with all his associated files
including his home directory and mail folder. How will you do that ?
#userdel -r [username]
Above command will delete user account as well all his associated files including his
home directory and mail folder.
A user comes to you and complain that his system was starting fine in GUI mode,
but from last reboot system is starting in command line interface. What is the most
likely cause of the problem?
In the /etc/inittab file, the default runlevel is probably set to 3, which tells it to start
the system in command line.
What files are updated when adding a group?
/etc/group and /etc/gshadow files contains group information in Linux system. So
these files would be updated every time whenever new group is added.
What command is used to delete a group?
The groupdel command will delete a group.
What runlevel does init 3 represent?
init3 represents rulevel 3. runlevel 3 is used for multiuser with networking.
What command will display the directory path that is currently in use?
pwd command will display the directory path that is currently in use.
A user type 'cd ~ ' on command prompt, what this command will do?
This command will move user to his or her home directory. ~ represents home
directory in Linux.
A user comes to you and complain that his system start fine, but as soon
as it is almost loaded it reboot again. What is the most likely cause of the
problem?
In the /etc/inittab file, the default runlevel is probably set to 6, which tells it to
reboot right after the system has started.
Which command will list all the files and sub-directories in a directory and
include the access rights?
ls -l command will list all the files and sub-directories in a directory and include the
access rights.
Which command will list all the files in a directory including hidden files?
ls -a command will list all the files in a directory including hidden files.
What is the correct syntax for the move command?
The correct syntax for the move command is
mv [options] [source] [destination]
Which character option with chmod command allows the execute-only
permission if the file is a directory?
The x option is used to allow execute only if the file is a directory.
How will you display confirmation of the change of ownership of a file from
rhuser1 to rhuser2?
Use --verbose option with chown command. For example
#chown --verbose rhuser2 /tmp/testfile
Which command is used to un-mount a DVD?
Use umount command to un-mount the DVD or CD or any other mounted media.
What runlevel does init 0 represent?
Runlevel 0 is used to halt /shutdown the system.
Which command will display the total size of all files, without listing the
files, in a user's home directory?
The command du -c -s /home/user will display the total size of all files, without
listing the files
Which command will display the available space of each partition in
megabytes (MB)?
The command df -m will display the available space of each partition in MB.
Hard drive in your system is full and you want new hard drive. However sales
department would not approve the expenditure without proof. Which tool would you
use get a proof?
Use RPM tools should be used to query or verify the installed packages to
RPM should be installed or upgraded by first using the test mode to verify
that it works, and then it should be installed
At the end query the RPM and verify the installation of RPM
Which organization controls the official releases and updates of the X Window
System?
The X Consortium at www.x.org controls the official release and updating of the X
Window System
PPP is most often used to create?
PPP is most often used to create serial point-to-point connections.
When attempting to connect to www.example.com you got unknown host
message. Which service is most likely not functioning properly?
DNS
Samba is used to provide support for which protocol?
Samba is used to support the Microsoft SMB/CIFS systems.
What command is used to load a module into the kernel?
The insmod command is used to load a module into the kernel
Name one of the most secure method of remote access.
SSH is the most secure method of remote access
With respect to a Linux systems RAM, how large should the swap file be?
Generally the size of the swap file should be twice the size of installed RAM.
How would you create a backup of the fstab file to the /backup folder?
Use cp command to create the backup.