Sunday, December 27, 2015

How to Delete Files/Directories?


Deleting files :-

syntax :- rm <filename>

using #rm <filename> , It will ask you confirm to delete file.
you can use #rm -rf <filename>,   It will delete without promting anything .

r- recursively  , f- forcefully

using * you can delete all related to that file name. You can see from below  example for above commands.


Deleting Directory :-

syntax :- rmdir <directoryname>    or  rm -rf  <directoryname>

Using above 2 commands you can delete directories without any prompt .

using # rm -rf *   , we can delete all the files and directories in that folder .  You can see same in below examples.




Thursday, December 24, 2015

How to Rescan the existing Disk ?



We can rescan the existing disk using below command.

Syntax :-

echo 1 >  /sys/class/scsi_device/device/rescan 

How to Change Hostname ?

"hostname" is the command to check current hostname .

syntax  to change hostname :-  hostname <serverhostname>

In below example you can see on how we can change hostname to linuxtechnotes.  Current server  hostname is  localhost.localdomain



From above screen you can see ,you need to relogin to change effect to shell .

Again , its temporary change . If you want to make it persistent during system boot . we need to specify new hostname in /etc/sysconfig/network file .



Wednesday, November 11, 2015

HOW TO CHECK NETBACKUP VERSION

To check netbackup version

# cat /usr/openv/netbackup/bin/version

To check netbackup agents running or not

# ps -ef | grep -i netbackup

HOW TO CHANGE ROOT PASSOWRD - UNIX

In order to change root password , you have to login to single user mode.
here are the sreps:-

1:- reboot the server
# reboot  or shutdown -r now  or if you are at console click on power button and click on restart

2:- while rebooting the server press any key for boot options

then press key "e" for edit

3:- Go to the kernel line and again press "e" for edit

4:-  space 1    

5:- press key "b" for boot

6:- after boot up the server to single user mode chnage the passwd using below steps

#passwd "enterpasswd"            (#passwd mypasswd)

7:- init 6 or reboot

Saturday, October 31, 2015

VGs(volume groups) are in DISABLED state

If the VGs are in DISABLED state ( check with the below commnd)

# vxprint -hvt

if VGs are in disabled state use below command

vxvol -g <diskgrp> startall


#  vxvol -g vgtstgrp startall

Thursday, October 29, 2015

umount: /mnt: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))


Yupp i was faced this issue many times.

when you see this issue

step1:-
 check and see you might be in same directory. in my case i was in /mnt and i am trying to unmounting. using umount /mnt command. (#umount /mnt)
then i got the below error

[root@test mnt]# umount -f /mnt
umount: Device or resource busy
umount: /mnt: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: Device or resource busy.

step2:-

if you are not in same directory and still you are getting this error means some prcoess are still holding this .

then try with -f   ( umount -f /mnt)

In some cases even -f option also wont help. Then check which process are running with fuser command.

#fuser -u /mnt  or
#fuser -m /mnt

you will get some process ID's which are running. So if you can kill those you can umount.

even it didnt help ? then you can try with "l" option.

# umount -l /mnt  ( l is lazy mount. you can check with man umount   for more options)

umount -l will work for sure.


if you still see stale error or  mount point even after lazy unmount. Then their could be chancess of issue is from NAS side. it means this server may not have permissions for this export.


X11 connection rejected because of wrong authentication.

xclock which is usually used to install some applications as GUI mode.

Below are the main packages which we have to install to work xclock

check with rpm command

# rpm -qa | grep -i xorg*

xorg-x11-drv-evdev-2.6.0-2.el6.x86_64
xorg-x11-utils-7.5-6.el6.x86_64
xorg-x11-font-utils-7.2-10.el6.x86_64
xorg-x11-xkb-utils-7.4-6.el6.x86_64
xorg-x11-server-common-1.10.6-1.el6.x86_64
xorg-x11-server-Xorg-1.10.6-1.el6.x86_64
xorg-x11-apps-7.6-6.el6.x86_64
xorg-x11-drv-ati-firmware-6.13.0-6.el6.noarch
xorg-x11-drv-vesa-2.3.0-2.0.1.el6.x86_64
xorg-x11-proto-devel-7.6-25.el6.noarch
xorg-x11-xauth-1.0.2-7.1.el6.x86_64
xorg-x11-fonts-misc-7.2-9.1.el6.noarch
xorg-x11-drv-void-1.4.0-1.el6.x86_64

>> check below config file is enlabled or not?       X11Forwarding yes   should be commentout

[root@test ~]# grep -i x11* /etc/ssh/sshd_config
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#       X11Forwarding no


>> make sure you added the right key
>> xauth list         <,,,you will get the output>>>>>>


#xauth add <add here which got xauth list output>

then it will be work. check with xclock commnd

#xclock


########################################
some more useful commands

echo $DISPLAY

export DISPLAY=localhost:10.0

#######################################

what is VERITAS main configuration file

Here is the veritas main configuration file.

# /etc/VRTSvcs/conf/config/main.cf

how to check server is in cluster or not

check with hastatus -sum  or with veritas main configiration file

# hastatus -sum

or

# cat /etc/VRTSvcs/conf/config/main.cf

based on output you can see the server is in cluster or not.

how to clear clonedisk

vxdisk set device clone=off

for example

#vxdisk set sdb clone=off          <<sdb,sda,sdc  it will vary. it depends on which device having                                                                                clonedisk>>>

Friday, October 23, 2015

AFTER REBOOT THE SYSTEM LOCAL LVM'S ARE MISSING (root file systems)

Usually we could see this issue when we reboot the server after the OS upgrade. we couldn't see the local root files systems  like /tmp /boot /var etc... or we could see from console like /dev/mapper/vg00-lvhome missing

Then you can give a try with below commands which will fix the issue.

the the below command

# mount –n –o remount,rw /

Then run the vgscan

# lvm vgscan

This should report finding the volume group vg00

Then run below command

 #mount –n –o remount,ro /

then rebooot the server again

 #reboot

after server is up you can see file systems using below command

# df -h


couldn't make OS upgrade due to lot of duplicate rpm's

yes some times couldn't make it due to lot of duplicate rpm's and dependencies.

if you could see the less packages you can remove manually. using nodeps command

# rpm -e --nodeps <pkg name>

>> If the issue is with lot  of dependencies.

Then try # yum update  --enablerepo=*

Actually yum itself means install dependencies as well. But somehow very rarely it couldn't install dependencies. it might be the reason some times new version package requires older versions. So give a try with
# yum update --enablerepo=*


its works for me.

Monday, October 19, 2015

line ** in /etc/fstab is bad

check in /etc/fstab , their should be a space issue.

for ex:-  exportfile mountpath  nfs  rw,nfsvers=4,soft 0 0

you can see above line from "rw" to "soft" their should be no space else you will get the error like line is bad in fstab.


how to check HP hardware info(chassis name, serial no )from command line


#dmidecode -t 204


you can see output as below
root@test ~]# dmidecode -t 204

Handle 0xCC00, DMI type 204, 11 bytes
HP ProLiant System/Rack Locator
       
        Enclosure Name: *****
        Enclosure Model: ********
        Enclosure Serial: *******
        Enclosure Bays: *******
       

Thursday, October 15, 2015

while running yum update Error: database is locked



try with yum clean

# yum clean all

how to send wall message to all logined users



login to server

wall "type your text message here "          

(or)

wall -n " type your text message here"    

chown: WARNING: Circular directory structure. This almost certainly means that you have a corrupted file system.


check the mount directory. it might be the new one. and their's no files in that directory and you might using -R. try with  without -R
#chown owner:group <directory>    < use this >
#chown -R owner:group <directory>    < when thier is no files in that mount direcotary you might get above error.> so try with without -R

Thursday, October 8, 2015

NEVER CRY IN YOUR LIFE


INPUT/OUTPUT ERROR FILESYSTEM IS UNMOUNTED ?

#############  INPUT/OUTPUT ERROR FILESYSTEM IS UNMOUNTED

> when you see df -h output as input/ouptput error.
> you need to deport and import the disk group. then it will be in good state.
> Before deport the diskgroup you need to unmount the all the filesystems.

#umount -a -t vxfs    << it means all type of veritas filesystems will be unmounted.
or #umount <fs name>

then deport the diskgrooup

check for diskgroup

#vxdisk list
#vxdg deport diskgroup
#vxdg import diskgroup
then mount  the filesystems
#mount -a

still if you see the issue  reboot is only the option

# reboot
or
#shutdown -r now

HOW TO DELETE ALL FILES AND DIRECTORIES IN A FOLDER


HOW TO DELETE ALL FILES AND DIRECTORIES IN A FOLDER

suppose you need to delete all files under /data/ramesh

using * we can delete all the files and directories

[root@tstvm ramesh]# ls -lrt
total 28
-rw-r--r--. 1 root root    0 Jul 17 07:57 ramesh
-rw-r--r--. 1 root root    0 Jul 17 07:57 b
-rw-r--r--. 1 root root    0 Jul 17 07:57 a
drwxr-xr-x. 2 root root 4096 Jul 17 07:58 kishore
drwxr-xr-x. 2 root root 4096 Jul 17 07:58 sam
drwxr-xr-x. 2 root root 4096 Jul 17 07:58 sai
drwxr-xr-x. 2 root root 4096 Jul 17 07:59 ram
drwxr-xr-x. 2 root root 4096 Jul 17 07:59 logs
drwxr-xr-x. 2 root root 4096 Jul 17 07:59 data
drwxr-xr-x. 2 root root 4096 Jul 17 07:59 apple
[root@tstvm ramesh]# rm -rf *
[root@tstvm ramesh]# ls
[root@tstvm ramesh]# ls -lrt
total 0
[root@tstvm ramesh]#
[root@tstvm ramesh]# pwd
/data/ramesh
[root@tstvm ramesh]#






How To Create a Group ? and Delete ?


Suppose if you want  add group called "technotes" and "linuxtech"
#groupadd linuxtech
#groupadd technotes

 linuxtech and technotes group enteris should be in /etc/group  




How to Delete ?
Syntax:- groupdel <groupname >





HOW TO CHANGE USER PASSWORD

syntax :- passwd <username>

suppose if you wanna change password for kishore

#passwd kishore

< then it will promt you to enter new passwd  then after it will prompt you retypepaswd



Below you can see its showing as only root can change .what does that mean ?

That mean only root can specify the username and delete . Suppose your trying to change the password for your userid you dont need specify the username . just change using passwd command as below .




Below you can see error " BAD PASSWORD: it is based on a dictionary word "   . Does this really error ?

Answer is no . its just warning stating paswwd is not secure as you might gave regular names . Always try to use atleast 6-8 characters including lower/upper case with numeric number .




HOW TO ADD USER



suppose if you wanna add users   sai and kishore.

Syntax :-  useradd <username>





HOW TO CHECK USER IS EXISTED OR NOT?



Using id command you will know either user is created on this server. In below example you can see  Sai,Kishore and Linuxtechnotes users existed .




Below you can see its showing  users linux and technotes not existed .



HOW TO CHECK USER LAST PASSWORD CHANGE AND EXPIRE DATE



using chage -l we can know the details
#chage -l



REBOOT/SHUTDOWN THE SERVER

HOW TO REBOOT THE LINUX SERVER

here are 2 ways to reboot the server

#reboot
#shutdown -r now


HOW TO SHUTDOWN/HALT THE SERVER

#shutdown -h now

HOW TO CHECK SERVER UPTIME( LAST BOOTED TIME)

#uptime

SERVER IS IN HUNG STATE AND NOT ABLE TO LOGIN.



>> If you are not able to login a server.First check from console,

>>From console end if server is running fine then it should be network issue.

>> Even from console if you see server is in hung state  LIKE  blank screen ,that  means server got hung.

>> Then the  only way is you need to reboot the sever. reboot will fix the issue.

SERVER IS IN HUNG STATE AND NOT ABLE TO LOGIN.



>> If you are not able to login a server.First check from console,

>>From console end if server is running fine then it should be network issue.

>> Even from console if you see server is in hung state  LIKE  blank screen ,that  means server got hung.

>> Then the  only way is you need to reboot the sever. reboot will fix the issue.

How To Differentiate b/w Files and Directories ?



[root@localhost linuxtechnotes]# ls -lrt
total 24
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes    0 Dec 19 21:38 linuxtechnotes
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes    0 Dec 19 21:43 linux1
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes    0 Dec 19 21:43 linux3
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes    0 Dec 19 21:43 linux2
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes   37 Dec 19 21:45 file1
-rw-rw-r--. 1 linuxtechnotes linuxtechnotes   52 Dec 19 21:47 file2
-rw-r--r--. 1 linuxtechnotes linuxtechnotes   19 Dec 21 19:28 redhat
drwxr-xr-x. 2 linuxtechnotes linuxtechnotes 4096 Dec 21 21:44 tech
drwxr-xr-x. 3 linuxtechnotes linuxtechnotes 4096 Dec 21 21:44 data
drwxr-xr-x. 2 linuxtechnotes linuxtechnotes 4096 Dec 21 21:50 linuxtechnote
[root@localhost linuxtechnotes]#




From the above list you can see files  start with  'd' means  DIRECTORY
                                                 '-' means  FILE

So from the above example  tech,data,linuxtechnote .... are directories  and linux1,linux2,linux3 and linuxtechnotes are files .


TO CHECK FILE PERMISSOINS USE ls -l or ls -ld
TO CHECK DIRECTORY PERMISSONS USE ls -ld  << you cant check direcotry permissons with ls -l >>



HOW TO KNOW SERVER IS PHYSICAL OR VMWARE ?


If you see out put as VMware virtual - it means virtual server

If you see output as Proliant BL*** - it means physical server

Below are the commands with examples

#dmidecode -s system-name-product
or
#dmidecode | grep -i product

examples:-
1)if its physical
# dmidecode -s system-product-name
ProLiant BL******
or
#dmidecode | grep -i product
  Product Name: ProLiant BL***
  String 2: Product ID: 1*****

2) IF its virtual server

#dmidecode -s system-product-name
VMware Virtual Platform

or
#dmidecode | grep -i product
  Product Name: VMware Virtual Platform
  Product Name: *****

HOW TO CAPTURE TCP DUMPS

>> using tcpdump you can capture all the interfaces
#tcpdump

>> if you wanna capture perticular interface

#ifconfig     << to check interfacess>>
# tcpdump -i eth0   <<give whatever interface you wanna capture eth0 or eth1......>>

using only tcpdump command you need to hit cancel. So if you usr "-c " option then it will take howmany packets you mentioned.
example
#tcpdump -c 20    << it will capture only 20 packets only>>

>> if you wanna capture 20 packets on interface eth0
#tcpdump -c 20 -i eth0

>> if you wanna capture 20 packets on eth0 interface with saved file on /tmp then you can use below command

# tcpdump -w /tmp/dump.pcap -c 20 -i eth0

-w for save on /tmp/  with dump.pcap file

-c for capture 20 packets

-i for capture on eth0 interface

here other things you need to remember if you have to view the captured file either you need wireshark tool or from command line using "r" option you can. see for example below

# cat dump.pcap    <<< you cant understand anything>>>
#tcpdump -r dump.pcap  << you can see now clearly>>


if you want capture for perticular interface and port

# tcpdump -i eth0 port 22

HOW TO GIVE SUDO ACCESS TO USER RUN TCPDUMP

make a backup of /etc/sudoers file

cp /etc/sudoers /tmp/sudoers.date

Then edit the /etc/sudoers file  here we can edit in 2 ways

1:- vi sudoers
or
2:- visudo

visudo is the recomandded to edit the sudoers file
here you go

# visudo
add below enterie  ( " suppose you need to give sudo access to ramesh" ) here what you need to add

ramesh ALL=(root) NOPASSWD: /usr/sbin/tcpdump

:wq!

Now user can run tcpdumps using below command

#sudo tcpdump**********************

HOW TO GIVE SUDO ROOT ACCESS TO USER


make a backup of /etc/sudoers file

cp /etc/sudoers /tmp/sudoers.date

Then edit the /etc/sudoers file  here we can edit in 2 ways

1:- vi /etc/sudoers
or
2:- visudo

visudo is the recomandded to edit the sudoers file
here you go

# visudo
add below enterie  ( " suppose you need to give sudo access to ramesh" ) here what you need to add

ramesh ALL=(root) NOPASSWD: ALL

:wq!

to get root access login with your user id then do

#sudo su -

will get root access

HOW TO CHECK/CHANGE FILE PERMISSIONS AND OWNERSHIP


Suppose you need to check /data Directory permissions

#ls -ld <dirname>

If you need to change owner and group    << for example you need to set linuxtechnotes as both owner and  group>>

#chown  linuxtechnotes:linuxtechnotes  /data


What if you want just change user permissions  to kishore ?



What if you want just change group permissoins to sai ?


What if you want change owner and group to linuxtechnotes to /data and all files under /data aswell ?


HOW TO CREATE A DIRECTORY


Syntax:-  mkdir <dirname>
example  #mkdir tech

Here another thing you need to know that is, if you need to create Directory including sub-directory then you need to use -p

#mkdir -p <dirname/subdirname>
example :- mkdir -p data/storage




VI EDITOR BASIC COMMANDS



Vim is a text editor that is upwards compatible to Vi.  It can be used to edit all kinds of plain text.  It is especially useful for editing programs.


"vi" to edit the file

"i" for insert mode

"esc" for back to normal mode

":q!" for quit the file with out saving the edited data

"shift+g" to go last line

"shift+a" to go to end of the line

"dd" to delete the entire line

"u" for undo

"yy/cursor right click" for paste

"left click on content" for copy

":wq!" for save and quit the file

" :set number " to set up the serial number for lines "

" :set nonu " to remove the serial number"

"o" to go fresh down line with insert mode

"O" to go fresh up line with insert mode

"j" down arrow

"l" right arrow

"h" left arrow

"k" up arrow



BASIC COMMANDS SHOULD LEARN AS UNIX/LINUX ADMIN


ls : list the files
touch :- to create the file system.

cat :- to view the content of the file

vi :- to edit/add the content in file.

for examples

Below you can see how you can list the files,create file "redhat" and add content  as "this is redhat file " and how can you cat redhat file.






Please see below for some more ls commands with examples  :-

ls List the  Files / directories 
ls –a List All files and directories including hidden Files 
ls -l List All information about files/directories
ls –ld List Directory Information 
ls -lt List Last Modified Time Using 
ls –r List files with reverse order
ls –ltr Order Files Based on Last Modified Time (In Reverse Order) Using
ls –R List  Files Recursively Using 
ls –lh List  files in KB, MB, etc
ls –m LIst  files with comma separation
ls –i Display File inode Number Using 
ls –q Hide Control Characters Using
ls –n Display File UID and GID Using 







You may want to know

how to differentiate b/w file and Directory ?

Tuesday, October 6, 2015

rsync warning: some files vanished before they could be transferred (code 24) at main.c(1039) [sender=3.0.6]

Does it really a issue in server/ rsync command which you used ?

Nope. Their is nothing to worry about the server/command rsync syntax which you used .

First lets understand on how rsync works ?

when ever we send rsync job  to copy a some set of files first it will catch up all the available cache and will start do copy process . So above error could be cause  that when we ran rsync command these files were available in cache but when its trying to copy them those are not available in server. so you can check that these files must not be available in source path. which must deleted by a application like any automation jobs which they usually do or some user might  have deleted as he suspected those are no longer needed .

To make it simple their is nothing wrong with rsync syntax. its simply warning saying this file was not available now in source path .

Tuesday, May 12, 2015

Saturday, March 21, 2015

How to list the label name ? how to change the label name ?



How to list the label name ?

e2label  <partitionname>
for ex :-  e2label /dev/sda


How to change the label ?

 e2label  <partitionname>   <newlabel name>

for ex :-  e2label  /dev/sda/labelname


How to mount a file system using label ?

mount -L <labelname>   <mount path>

Fstab entries for LABEL filesystem >

LABEL=<labelname>    <mountpath>     <filesystem type>     default 0 0

Monday, February 2, 2015

Ulimit (Nproc/Nofile) Configuration in Linux ?


What is the main configuration file ?

/etc/security/limits.conf
/etc/security/limits.d/*

So we have two files ? where do we need to change the values ?

we can make changes to any of above 2 files .But make sure values must present in any of one file . Else limits.d file will overwrite to limits.conf .

How can we check the current all ulimit values ?

Command # ulimit -a      will give all the current values in system . you can see in below example .




what is default nofile/nproc value in Linux ?

Typically the default value for nofile /nproc  is 1024 or 4096.


what is nofile /open file ? how can we check ?

nofile  is nothing but num of open files . noflie value is the one which controls  the user threshold on how many open files a user  can open in a system .

In Example below user paul can open 1024 open files in  system .


[paul@linuxtechnotes ~]$ whoami
paul
[paul@linuxtechnotes ~]$ ulimit -n
1024
[paul@linuxtechnotes ~]$

How can we know that how many files opened by user "paul' ?

lsof is the command which gives  the list of open files .From the below example you can see that num of files opened by root is 5802 and num of files opened by paul is 657.


[root@linuxtechnotes ~]# whoami
root
[root@linuxtechnotes ~]# lsof | wc -l
5802
[root@linuxtechnotes ~]# su - paul
[paul@linuxtechnotes ~]$
[paul@linuxtechnotes ~]$
[paul@linuxtechnotes ~]$ whoami
paul
[paul@linuxtechnotes ~]$ lsof | wc -l
657

[paul@linuxtechnotes ~]$


what is nproc  ? how can we check ?

nproc  is nothing but num of open process in a system  . nproc  value is the one which controls  the user threshold on how many open process a user  can open in a system .

In Example below user paul can open 1024 open process in a system .

[paul@linuxtechnotes ~]$ whoami
paul
[paul@linuxtechnotes ~]$ ulimit -u
1024
[paul@linuxtechnotes ~]$
[paul@linuxtechnotes ~]$


How can we know that how many process opened by user "paul' ?

ps -ef  is the command which gives  the list of open files .From the below example you can see that num of process  opened by root is 155 and num of files opened by paul is 157.


[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# whoami
root
[root@linuxtechnotes ~]#
[root@linuxtechnotes ~]# ulimit -u
15003
[root@linuxtechnotes ~]# ps -ef | wc -l
155
[root@linuxtechnotes ~]# su - paul
[paul@linuxtechnotes ~]$ ulimit -u
1024
[paul@linuxtechnotes ~]$
[paul@linuxtechnotes ~]$ ps -ef | wc -l
157
[paul@linuxtechnotes ~]$


How can we know the issue is with nproc/nofile(open file) ?

If any user getting error like "maximum num of open sessions/limit/file exceeds then that mean user exceeds the threshold to open a files.

When user is trying to login his/her account . If he get error like Resources are temporarily not available then that mean user exceeds the num of open process .

How can we increase the nproc/nofile value limit  ?

Nproc :-

lets assume we are going to increase nproc value for paul to 5000. Below we can see on how can we do 

[root@localhost security]# cd limits.d
[root@localhost limits.d]# ls
90-nproc.conf
[root@localhost limits.d]#
[root@localhost limits.d]# cat 90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited
[root@localhost limits.d]# su - paul
[paul@localhost ~]$ ulimit -u
1024
[paul@localhost ~]$ whoami
paul
[paul@localhost ~]$ exit
logout
[root@localhost limits.d]# whoami
root
[root@localhost limits.d]# vi 90-nproc.conf
[root@localhost limits.d]# cat 90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited
paul soft nproc 5000
paul hard nproc 5000
[root@localhost limits.d]# su - paul
[paul@localhost ~]$ ulimit -u
5000
[paul@localhost ~]$ whoami
paul
[paul@localhost ~]$




Nofile :-

lets assume we are going to increase nofile for paul to 5000. Below we can see on how can we do 

[root@localhost limits.d]# cat 90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited
paul soft nproc 5000
paul hard nproc 5000
[root@localhost limits.d]# su - paul
[paul@localhost ~]$ ulimit -n
1024
[paul@localhost ~]$ whoami
paul
[paul@localhost ~]$ exit
logout
[root@localhost limits.d]# vi 90-nproc.conf
[root@localhost limits.d]# cat 90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited
paul soft nproc 5000
paul hard nproc 5000

paul soft nofile 5000
paul hard nofile 5000
[root@localhost limits.d]# su - paul
[paul@localhost ~]$ ulimit -n
5000
[paul@localhost ~]$
[paul@localhost ~]$ whoami
paul
[paul@localhost ~]$




what is the main file which controls the ulimit value for system wide ?

[root@localhost ~]# cat /proc/sys/kernel/threads-max
30006
[root@localhost ~]#
[root@localhost ~]#


Earlier I mentioned that limits.d will overwrite limits.conf file . Below you can see how it works ?


Below you can see ulimit values setup in limits.d file for user "john" and thier is nothing in limits.conf

[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ cat /etc/security/limits.conf | tail -3
#@student        -       maxlogins       4

# End of file
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ 


Now below you can see i have setup values as 65535 in limits.conf file and 8000 in limits.d file . you can see below on which file wins 


[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ cat /etc/security/limits.conf | tail -3
#@student        -       maxlogins       4

# End of file
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ exit
logout
[root@linuxtechnotes ~]# vi /etc/security/limits.conf
[root@linuxtechnotes ~]# cat /etc/security/limits.conf | tail -5
# End of file
john soft nofile 65535
john hard nofile 65535
john soft nproc 65535
john hard nproc 65535
[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ whoami
john

[john@linuxtechnotes ~]$ exit



so as you see above limits.d wins . its means limits.d over writes to limits.conf file . Now Below lets try to remove the values in limits.d file and see which values reflects .


[root@linuxtechnotes ~]# cat /etc/security/limits.conf | tail -5
# End of file
john soft nofile 65535
john hard nofile 65535
john soft nproc 65535
john hard nproc 65535
[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 8000
max user processes              (-u) 8000
[john@linuxtechnotes ~]$ whoami
john
[john@linuxtechnotes ~]$ exit
logout
[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited

john  soft nproc 8000
john  hard nproc 8000
john  soft nofile 8000
john  hard nofile 8000

[root@linuxtechnotes ~]# vi /etc/security/limits.d/90-nproc.conf
[root@linuxtechnotes ~]# cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     1024
root       soft    nproc     unlimited


[root@linuxtechnotes ~]# su - john
[john@linuxtechnotes ~]$ ulimit -n -u
open files                      (-n) 65535
max user processes              (-u) 65535
[john@linuxtechnotes ~]$ whoami
john

[john@linuxtechnotes ~]$