RHCSA-4 Basic Concepts and Commands
RHCSA-4 Basic Concepts and Commands
• Brace Expansion
Brace expansion is used to generate flexible strings or character.
[root@srv data]# mkdir {1..8}
[root@srv data]# touch {1..8}.txt
[root@srv data]# touch {a..z}.{txt,mp3}
[root@srv data]# touch {a..c}{1..3}.{txt,mp3}
[root@srv data]# touch {a{1..3},b,c}.{txt,mp3}
[root@srv data]# mkdir {a,b,c,{1..5}}
[root@srv data]# mkdir {{1..9},{a..g}}
Basic Commands of Linux
[root@srv ~]# cd “change to the user’s home directory.”
[root@srv ~]# cd /root/Desktop/ “Change the directory”
[root@srv Desktop]# cd .. “to move back one directory from the current
directory.”
[root@srv ~]# cd ../.. “move back two directories from the current
directory.”
[root@srv ~]# ls “list directory contents”
-a “do not ignore entries starting with .”
-lh “shows file or directory, size human readable, modified date
and time, file or folder name and owner of file and its permission.”
-R “option will list very long listing directory trees.”
-lrt “shows latest modification file or directory date as last.”
-n “To display UID and GID of files and directories.”
[root@srv ~]# ls -ld /tmp/ “Show specific directory info”
Basic Commands of Linux
[root@srv ~]# cat abc.txt “Show the content of file”
[root@srv ~]# file as.txt “To identify the file type”
[root@srv ~]# head /etc/passwd “Show file content from starting 10 line”
[root@srv ~]# head -n 20 /etc/passwd “you can define no of line display”
[root@srv ~]# tail /etc/passwd “Show file content from ending 10 line”
[root@srv ~]# tail -n 20 /etc/passwd “you can define no of line display”
[root@srv ~]# wc as.txt “Count the no of word, line character”
-l = Lines counts
-w = Word counts
-c = Character counts
[root@srv ~]# history “To show the history of commands”
Note- history are stored into “.bash_history” file. It can contain up to
5000 commands.
I/O Pipes Redirection
• Standard Input (Channel 0) reads input from the keyboard.
• Standard Output (Channel 1) sends normal output to the terminal.
• Standard Error (Channel 2) sends error massages to the terminal.
STDIN Examples-
“<“ = redirect input in a file
cat < file-name
[root@srv ~]# cat < a.txt
mail –s “Subject” username < file-name
[root@srv ~]# mail -s "hello world" root < /root/file.txt
cat > “file-name” <<“end with some character or word”
I/O Pipes Redirection
STDOUT Examples-
> = redirect output to overwrite a file.
>> = redirect output to append a existing file.
[root@srv ~]# df -hT > as.txt
[root@srv ~]# ll >> as.txt
STDERR Examples-
2> = redirect output to overwrite a file.
2>> = redirect output to append a existing file.
[root@srv ~]# ll /etcw 2> err.txt
Thank you