Saturday 21 October 2017

Basic Linux Commands


To check server uptime
[root@ducat Desktop]#uptime
To check which users has logged in on you server and there terminals
[root@ducat Desktop]#who
           Or
[root@ducat Desktop]#w
To check login details of the users
[root@ducat Desktop]#lastlog 
To check the linux operating system
[root@ducat Desktop]#cat /etc/redhat-release
To check the kernel of operating system
[root@ducat Desktop]#uname
                     uname –s    (only for kernel name)
                     uname –m    (machine architecture)
                                                  uname –a    (for complete details)
                     uname –n    (for computer name)
                     uname –v    (kernel version)
                                                  uname –r    (kernel release)
                     uname –i
                     uname –o    (OS name)
To check computer name
[root@ducat Desktop]#hostname
      Or
[root@ducat Desktop]#hostnamectl    (only for rhel 7 or centos 7)
To change computer name
[root@ducat Desktop]#hostnamectl set-hostname “redhatserver”
To check date and time of system
[root@ducat Desktop]#date
                  Or
[root@ducat Desktop]#timedatectl    (only for rhel7 or centos 7)
To change date and time of system
[root@ducat Desktop]#date 020114252014
                  Or
[root@ducat Desktop]#timedatectl set-time “2017-07-18 10:32:00”
To change timezone
[root@ducat Desktop]#timedatectl set-timezone “Asia/Kolkata”
To check available timezone
[root@ducat Desktop]#timedatectl list-timezones
To check the calendar of current month
[root@ducat Desktop]#cal
                        cal -3      (last, current and next month)
                        cal 2014    (year)
                        cal 5 2014  (specific month of the year)
To print hardware details
[root@ducat Desktop]#lspci
To print cpu details
[root@ducat Desktop]#lscpu
To check the directory structure
[root@ducat Desktop]#dir
      Or
[root@ducat Desktop]#ls
[root@ducat Desktop]#ls –l or ll (for complete details)
[root@ducat Desktop]#ls –lh   (size in human readable formate)
[root@ducat Desktop]#ls –la   (print hiden files and folders)
To check the working directory
[root@ducat Desktop]#pwd
To create a directory
[root@ducat Desktop]#mkdir
To create directory tree
[root@ducat Desktop]#mkdir –p /test/{a/{ab,ab1,ab2},b,c}
To change working directory
[root@ducat Desktop]#cd directory path
                     cd    (switch into home directory)
                                                  cd ..       (Execute parent directory)
To remove directour
[root@ducat Desktop]#rmdir directory name
To create empty file
[root@ducat Desktop]#touch file name
To check the contents of file
[root@ducat Desktop]#cat file name                     
To rename file
[root@ducat Desktop]#mv koko.txt koko1.txt
To copy file
[root@ducat Desktop]#cp koko1.txt /kuldeep/1/a
To show the directory tree
[root@ducat Desktop]#tree /kuldeep/
To move file
[root@ducat Desktop]#mv koko1.txt /kuldeep/2
To delete directory
[root@ducat Desktop]#rm -rf /kuldeep1?
To delete all directories starts with kul keyword
[root@ducat Desktop]#rm -rf /kul*
To show the history
[root@ducat Desktop]#history
To print last number of commands
[root@ducat Desktop]#history 5
To check the login user name
[root@ducat Desktop]#whoami


how to set time for internet use

this will allow internet access for a particular time interval. R4(config)#int f0/0 R4(config-if)#ip nat inside R4(config-...