Saturday 16 September 2017

conditional execution of commands in linux

if the first command is executed successfully then execute the second command in linux
example
       if the kuldeep folder is present at your working directory then this will create test.txt file in this folder.
[root@localhost~]#ls -ld kuldeep && touch kuldeep/test.txt

if the first command does not execute successfully then execute the second command in linux
example
      if the kuldeep folder is not present at your working directory then this will create it
 [root@localhost~]#ls -ld kuldeep || mkdir kuldeep

pls put your comments and suggestion.

Friday 15 September 2017

how to search a keyword and replace in linux using vim text editor

[root@localhost ~]# vim testfile.txt
# go to the execution mode of vim
:%s/keyword/neword/ig
#option i is use for ignore case
#option g is use for global search
#only draw back is this will not match exact keywork you use this as
:%s/\<keywork\>/newword/ig
#this will match exact keyword and replace with new.

Thursday 14 September 2017

how to set login message in linux

[root@localhost~]#vim /home/msg.sh
#!/bin/bash
dialog --title "welcome message"\
           --infobox "welcome $USER. welcome to linux system.\
                            your login time is ( `date`)" 7 50; sleep 5
:wq
[root@localhost~]#chmod +x /home/msg.sh
[root@localhost~]#vim /etc/profile
#"at the end of file"
/home/msg.sh
:wq
now log out your user then relogin it


pls put your comment and suggestion.

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-...