Introduction to CLI Flashcards
What characters tells that a prompt is for a normal user
$
What characters tells that a prompt is for root user
#
Execute command1 and command2 unconditionally one after the other
command1 ; command2
Execute command2 after command1 only if later is successful
command1 && command2
Execute command command2 after command1 if the later fails
command1 || command2
Print the time
date +%R
Print the date in the format 02/27/2022
date +%x
Determine the type of the file /tmp/file-name.ext
file /tmp/file-name.ext
Show the inode of the file newfile.txt
ls -li newfile.txt
Create hard link of file newfile.txt
ln newfile.txt /tmp/newfile-hlink2.txt
Limitations of hard links
1) No cross file systems
2) Not applicable to folders
How do you know the file system that a set of files are on
df
Create symbolic link
ln -s /home/user/newfile-link2.txt /tmp/newfile-symlink.txt
Create folders RHEL8, RHEL7, RHEL9 in one command without writing RHEL many times
mkdir ../RHEL{7,8,9}
Print today day of the week
date +%A
Search man pages by keyword in titles and descriptions
man -k passwd
Interesting man page sections
Page 1: Normal user
Page 5: Config
Page 8: Admin
Search man pages by keyword in full-text page, not only in the titles and descriptions
man -K passwd
Open man page 1 for command gedit
man 1 gedit
Redirect stdout and stderr to the same file
> file 2>&1
login to machine remoteuser@remotehost with cert mylab.pem
ssh -i mylab.pem remoteuser@remotehost
Shortcut to reuse the argument of the previous command
Esc + .
Repeat the previous command
!!
Important RHEL directories
/boot
/root
/home
/var
/usr (/usr/sbin, /usr/bin, /usr/local)
/etc
/run
/dev
/tmp