Some Linux Concepts.



  • How to check the utilisation of each cores: mpstat -P ALL 1 & lscpu or cat /proc/cpuinfo 
  • ps -aeF  gives the details of which core ID is being used for a process.
  • top -H -p => gives all the details of threads of all the processes.
  • lsof -t => Gives the PID of a file name.
  • netstat -a => all ; listening + established; -n => suppress host/port name resolution; -t => only tcp ; -p => program name; -r routing; -i interface 
  •  Find files smaller than 2K: find -type f -mindepth 2 -size -1c
  •  Find files which are not older than 2 days: find -type f -mtime -2 
  • stat zzz (Gives all the statistics of a file); stat %i ; %F; %G; %U; %b ; atime => when it was last accessed , mtime => when the file was last modified, ctime when the file was  last changed (changed means file attributes were changed) 
  • Unix File system: A directory has name & a number; number  refers to a inode location where Group/User ID, permissions, files/directory, references to data blocks are presents & the actual data resides in data blocks.
  • chmod rwx+ugo   or chmod u+rwx,g+xr,o+r  or chmod u=rwx,g=xr,o=r or chmod 776  
  • chown or, chgrp
  •  PS1="[\u@\h]" ==> set the primary terminal as [user@hostname]  => set the primary terminal name 
  • pr => minor formatting of the file.
  •  
  • add line  :set backupcopy=yes in /var/home/root/.vimrc for 'crontab: no changes made to crontab' error
  • in VI, d^ => delete from curser to start; d$ => delete from the curser to end ; yy => copies the current line; p => paste the copied line
  • vi => :w filename (copy to filename):2r filename (paste lines from the filename to curent after 2nd line) :e filename (Open another filename) :e # (toggle between two files)
  •  ulimit is used to limit the file size, no of open files,cpu time, max user processes. ulimit -a gives the details of what those attributes are set

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) 24655
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 159878
max locked memory       (kbytes, -l) 24655000000000
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
  • Execution sequece in unix,when first log into .bash_profile, then .bash_login, then .bashrc 



Comments