Professional Documents
Culture Documents
a. 'mkdir temp'
b. 'rm -rf temp[34]' - removes a range of items using Regular Expression (RegEx) - Character-Class
To remove the selected directories we use the following cmmd , this cmmd remove only temp3 and
temp 4 directory not temp2
You can use character class with any linux cmd here we list the temp 3 & 4 files content.
for ‘ls’ it is showing the alias , alias means the second name of cmd the primary cmd generally have
options associated with the cmd like ls given below here option is color
14. 'echo $PATH' - reveals the current $PATH for the executables
As you can see that these are the path for the user linuxcbt , path are delimited with : and when you
search for the path it will start finding the path from left to right in the paths given for the user and path
may differ according to the users.
15. Redirection:
c. '>>' - APPEND - appends to target file if it exists and creates it if it doesn't :** studied here only
Examples:
Note: However, most commands will wait for keyboard input if no input file is specified
16. Linux | UNIX Pipes - connects output stream of command a to input stream of command b
a. 'cat /var/log/messages | less' - pipes output of 'cat...' into 'less' (/var/log/messages : this is the main
system log file)
b. 'cat /var/log/messages | grep kernel | less' - parses '/var/log/messages' for keyword 'kernel' then
pipes the output to 'less' to display one pageful at a time
b. 'rm -rf temp* ; ls -l' - runs both commands independently in Linux ‘;’ means the next line command
to execute
Note: Command Chaining is not dependent upon the exit status of the most-recently executed
command
by the OR Condition means that ls –l will run only if rm –rf fails so as we see the output rm –rf executed
that is why we didn’t get the ls –l output.
b. 'rm -rf temp* && ls -l' - run 'ls -l' if and only if 'rm -rf temp*' works
It will create the logical dependency so ls –l only run if rm –rf will get executed.
As you can see that in below condition we have logical AND if the initial cmd is not coreect then all other
cmds in the chain will not executed , so what it means that execution of any cmd in cmd chaining will
depend on the the correct execution of previous cmd.
Here we are using the OR Condition in the below PS it shows that first we failed pwd by typing pwds so
ls executed then we type pwds and lss to make these both cmd fail the ‘ps’ executed
19. Command History - built-in command (BASH) that means it is within bash intrepreter as
aconsequence there is no file on the disk that corelate with this cmd but it is available at your disposal
courtesy of shell
a. 'history'
bash shell maintain the history of all commands on per user basis
By running history cmd it will shows are cmds which shows list of all cmds that was run on this shell the
history itme is maintained in the home directory ‘.bash_history’ note that we write this ls cmd like
Here cat shows the history of cmds from the first tty shell
Here you saw the hidden file like .bash_history etc
b. 'LOGNAME'
c. 'SHELL'
etc.
‘set’ cmd will also the variables
Note : export of this variable ‘/tmp’ is specific to this shell only if you check on the other shell it will not
show this variable.