Linux Command by NischalTechSupport
Linux Command by NischalTechSupport
### Permission
~$chmod u+s <file> #set suid bit such as -rwsr-xr-x. small s means (rwxs)
~$chmod 4655 <file> #set suid bit such as -rwSr-xr-x. capital S means (rws)
~$Setgid on dir, all dir/files in it will get same ownership as parent dir.
It doesn't matter who is creating
~$chmod g+s <dir/file> #setting setgid bit
~$chmod 1777 <dir> #setting sticky bit such as drwxrwxrwt. small t means
(rwxt)
~$chmod 1776 <dir> #setting sticky bit such as drwxrwxrwT. capital T means
(rwt)
~$chown -R <user>:<group> <dir> #asssigning recursive permission of all
files/dir in target dir
~$useradd <user>
~$useradd -g itadmin -c "DB User" -u 1135 -s "/bin/sh" -d /home/techguy1
In the above command, we are creating the new user with custom options as
simple "#useradd <user>" will create with default setting. The -g (group) -c
(description) -u (user id) -s (which shell to be assigned) -d (landed home dir)
~$useradd -g <primary group> -G <secondary group> <user> # assign the user
primary and secondary group
~$passwd -l <user> #locking password of user
~$passwd -u <user> #unlocking password of user
~$passwd -e <user> #expire password
~$echo 'myPassword123' | sudo passwd --stdin <user>
~$passwd -x -1 <user> #Turnoff password expiry
~$usermod -L <user> #locking user
~$usermod -U <user> #unlocking user
~$chage #set password expiry
### Process
### Network
### Memory/Swap
### Disk
~$df -h
~$df -Th
~$du -sh <path/*>
~$du -sch .[!.]* * | grep --regex="[0-9]*G"
~$lsof -u <user> #list of openfiles by specific user
~$lsof | grep delete #list of openfiles that are deleted
~$lsof | awk '{print $1}' | sort | uniq -c | sort -r -n #sort number of open
files by process
### SFTP/SCP
### Sed
### find
~$find /tmp/* -mtime +7 -exec rm {} \; #remove files from dir "tmp/" that are
older than 7 days
~$find /home/ -type f -name ".errors*.gz" -mtime +7 -exec rm {} \; #remove
files from dir "tmp/" that are older than 7 days - with filename
~$find /home/ -type f -size +500M -name "*tempfile*" -exec du -sh {} \;
#found the tempfile that has file size >500MB
~$find /home/ -type f -size +1G -exec ls -lh {} \; | awk '{ print $9 "|| Size
: " $5 }' #find output in custom defined format like in this "dirname || Size:_"
### Additional
~$top -b -n 1 | head -n +5
~$uptime
~$sestatus #check selinux status