Sunday 5 July 2020

What is RPM?


176. What is RPM and How to check dependencies of RPM Package on before Installing ?

RPM is a Package Manager for popular distribution such as Red Hat, Suse and many others. It is a powerful command line package management system for installing uninstalling, verifying, querying, and updating Linux computer software packages.

rpm -qpR {.rpm-file}
rpm -qR {package-name}

-qpR above is equivalent to --query --package --requires.

177. How can we increase disk read performance in single commands?

To see the current read performance,

$ blockdev –getra /dev/sdb
256

$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2549+1 records in
2549+1 records out
copied, 6,84256 seconds, 97,7 MB/s
real 0m6.845s
user 0m0.004s
sys 0m0.865s

After test,
$ blockdev –setra 1024 /dev/sdb

$ time dd if=/tmp/disk.iso of=/dev/null bs=256k
2435+1 records in
2435+1 records out
copied, 0,364251 seconds, 1,8 GB/s
real 0m0.370s
user 0m0.001s
sys 0m0.370s

178. How do i check which NFS version ?

$ rpcinfo -p localhost | grep -i nfs
$ rpm -qa | grep nfs
$ rpm -qi nfs nfs-utils

179. What is the command for extract RPM?

$ rpm2cpio

example,
$ rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv

i: Restore archive
d: Create leading directories where needed
m: Retain previous file modification times when creating files
v: Verbose i.e. display progress

Verify that you have extracted an RPM file in the current directory:
$ ls

180. Assume the / partition got read only error, what steps has to be take.

$ remount –o rw,remount

181. Please let us know how to stop the ssh service from a particular node?

$ /etc/hosts.deny a sshd: ALL except Node IP

182. How to check whether the ssh is running or not on the remote host?

# nmap   -p  22    <IP address of the remote host>    (to see the ssh is running or not on remote system)

183. Step out if you are facing too many file system while login via ssh?

# lsof |wc -l #(list of open files)

# sysctl -a | grep file-max # check system capacity

# ulimit -n

Try ulimit -n -H which will show the "hard" limit for open files (-n), for example 4096. Then raise the limit to that value eg: ulimit -n 4096 before invoking your SSH tunnel.

Increase the limit by going through limits.conf file which is available in the location /etc/security/limits.conf. Now add the below content in the file "limits.conf".

soft nofile value
hard nofile value

184. What is linux library file extension?

On Linux, dynamic libraries typically have a .so (shared object) extension. One advantage of dynamic libraries is that many programs can share one copy, which saves space.

185. What is relevance of $?

It reflects the status of previous command,

1. If 0 – Success
2. If Non-Zero – Not Success

186. Which Terminal you are working in?

Find it using ‘tty’ command or who command

187. Command ifconfig is not found in my system, how to get my ip address

# ip a

188. What is ErrorDocument?

The Apache web server provides a default set of generic error pages for 404, 500, and other common Apache errors. The ErrorDocuments directive lets you specify what happens when a client asks for a nonexistent document. Specifies a file that the server sends when an error of a specific type occurs. You can also provide a text message for an error. 

Here are some examples:

ErrorDocument 403 “Sorry, you cannot access this directory”
ErrorDocument 403 /error/noindex.html
ErrorDocument 404 /cgi-bin/bad_link.pl
ErrorDocument 401 /new_subscriber.htm

400: Bad Request
401: Unauthorized
402: Payment Required
403: Forbidden
404: Not Found
405: Method Not Allowed
406: Not Acceptable
407: Proxy Authentication Required
408: Request Timeout
409: Conflict
410: Gone
411: Length Required
412: Precondition Failed
413: Request Entity Too Large
414: Request-URI Too Long
415: Unsupported Media Type
416: Requested Range Not Satisfiable
417: Expectation Failed
500: Internal Server Error
501: Not Implemented
502: Bad Gateway
503: Service Unavailable
504: Gateway Timeout
505: HTTP Version Not Supported

189. Find SGID Files with 644 Permissions?

# find / -perm 2644

190. Specify number of maximum open files in a single login based on the amount of system RAM?

# echo “1599383” > /proc/sys/fs/file-max

This can also be done by using sysctl
sysctl command is used to change Kernel Parameters at run-time
# sysctl -w fs.file-max=1599383

Kernel Parameters can also be changed by making changes in the below file:
/etc/sysctl.conf

Append the below line in the /etc/sysctl.conf file
fs.file-max = 1599383

After making the above change run the below command for changes to reflect, loads the sysctl settings
# sysctl -p

191. Increase the local port range, by default the port range is small?

# echo “1024 65535″ > /proc/sys/net/ipv4/ip_local_port_range This can also be done using sysctl command

# sysctl -w net.ipv4.ip_local_port_range=”1024 65535”

Append the below line in the /etc/sysctl.conf file
net.ipv4.ip_local_port_range = 1024 61000

After making the above change run the below command for changes to reflect, loads the sysctl settings
# sysctl –p

192. How can an administrator know whether a user account is locked or not?

To check if the user account is locked or not just run this command in the shell:
passwd –S <username>

# passwd --status <username>

Check for the flag *LK* in the below command output which indicates that the account is locked.

Or search for the grep username in the location /etc/shadow file and it will show a symbol ‘!’ prefix to the encrypted field in the password box.

To just unlock the password type this command:
# passwd –u <username>

If there is a double exclamation mark then run this command two times:
# usermod –U <username>

193. How to lock user account or disable user account in Linux? How to check and enable?

Locking or disable user account is done for the security purpose so that unauthorized users cannot login. There are several ways in which user account can be locked or disabled. Some of them are below. 

1.Lock or disable the password using passwd command.
# usermod -L <username>
# passwd -l <username>

To check
# passwd --status <username>

To enable
# passwd –u <username>

2.To completely disable user accounts you can user the command chage -E0. For example :
# chage -E0 <username>

To check
# chage -l <username>

To enable
# chage -E YYYY-MM-DD <username>

3.Changing the shell using nologin command ( /sbin/nologin ).
so that the user do not get any login shell when he tries to login into the system.

# usermod -s /sbin/nologin <username>
check for the 7th and last field in /etc/passwd for the change of shell to /sbin/nologin.

To check
grep ^<username> /etc/passwd

To enable
# usermod -s /bin/bash <username>

194. When we execute ‘usermod‘ command in terminal, what are the files used and affected.

/etc/passwd – User account information.
/etc/shadow – Secure account information.
/etc/group – Group account information.
/etc/gshadow – Secure group account information.
/etc/login.defs – Shadow password suite configuration..

195. How to change user home directory?

check the current home directory of a user using the following command,
# grep <username> /etc/passwd

change home directory from /home/<username> to /var/www/,
# usermod -d /var/www/ <username>

196. How to set user account expiry date?

check the current account expiry status using,
# chage -l <username>

To set user account expiry date,
# usermod -e YYYY-MM-DD <username>

197. How to change password expiry to specific date?

check the current account expiry status using,
# chage -l <username>

To change password expiry to 120 days,
#  chage -M 120 <username>

To Change the password to never expire,
# chage -m 0 -M 99999 -I -1 -E -1 <username>

This will set the following,

Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999

198. How to change user primary group?

To check the current group for the user,
# id <username>

To set or change a user primary group,
# usermod -g <new_gid> <username>

199. How to add a new group to existing group?

#  usermod -G <gid> <username>

200. How will you figure out the author of each file?

#  ls --author -l

                                                                                           MENU         PREVIOUS | NEXT

No comments:

Post a Comment