This is part of the independent and unofficial RHCSA Exam Study Guide series providing free π€ resources to prepare for the exam.
This post covers the objectives under the section:
βUNDERSTAND AND USE ESSENTIAL TOOLSβ
It contains two main parts:
- Resources: with links to learn and practice for each objective.
- Cheatsheet: containing some examples of commands and actions performed in each objective (when applied).
π Resources:
ACCESS A SHELL PROMPT AND ISSUE COMMANDS WITH CORRECT SYNTAX
π RHCSA v8 Practice Session: Access a shell prompt and issue commands with correct syntax
π The bash shell
π Shell commands
π Bash bang commands: A must-know trick for the Linux command line
USE INPUT-OUTPUT REDIRECTION (>, Β», |, 2>, ETC.)
π RHCSA v8 Practice Session: Use input-output redirection
Manual Pages:
man bashthen/^redirection
USE GREP AND REGULAR EXPRESSIONS TO ANALYZE TEXT
π RHCSA v8 Practice Session: Use grep and regular expressions to analyze text
π How to use grep
π How To Use Basic Regular Expressions to Search Better and Save Time
ACCESS REMOTE SYSTEMS USING SSH
Attention: You must create another RHEL virtual machine and setup the ssh server at the new VM in order to practice for this objective.
π An overview of installing Red Hat Enterprise Linux 8 on a new virtual machine using VirtualBox (this is a setup step!)
π Install ssh server on CentOS 8 / RHEL 8 (this is a setup step!)
π RHCSA v8 Practice Session: Access remote systems using SSH
π Getting Started With SSH in Linux (skip βMounting remote filesystem or directoryβ and what comes after)
π SSH Usage, Tips, and Tricks (episodes 1 to 3)
LOG IN AND SWITCH USERS IN MULTIUSER TARGETS
ARCHIVE, COMPRESS, UNPACK, AND UNCOMPRESS FILES USING TAR, STAR, GZIP, AND BZIP2
π RHCSA v8 Practice Session: Archive, compress, unpack, and uncompress files
π Taming the tar command: Tips for managing backups in Linux (skip βHow to split a backup into smaller backupsβ and what comes after.)
CREATE AND EDIT TEXT FILES
π LCL 04 - the vi text editor - basic intro - Linux Command Line tutorial for forensics
π Vim Tutor Exercises (or just type
vimtutorin the terminal and play along.)
CREATE, DELETE, COPY, AND MOVE FILES AND DIRECTORIES
π RHCSA v8 Practice Session: Create, delete, copy, and move files and directories
π Create, delete, copy, and move files and directories β RHEL 8 RHCSA
CREATE HARD AND SOFT LINKS
LIST, SET, AND CHANGE STANDARD UGO/RWX PERMISSIONS
π RHCSA v8 Practice Session: List, set, and change standard ugo/rwx permissions
π How to manage Linux permissions for users, groups, and others
π What is umask and how is it determined on a Linux system?
LOCATE, READ, AND USE SYSTEM DOCUMENTATION INCLUDING MAN, INFO, AND FILES IN /USR/SHARE/DOC
π RHCSA v8 Practice Session: Locate, read, and use system documentation
π RTFM! How to Read (and Understand) the Fantastic Man Pages in Linux
π Search All the Linux Man Pages For a Particular Command or Text
π Cheatsheet:
ACCESS A SHELL PROMPT AND ISSUE COMMANDS WITH CORRECT SYNTAX
ttyβ‘ print current terminal name.uptimeβ‘ show systemβs uptime and load.which,whereis,typeβ‘ can be used to identify a command location.uname -aβ‘ print system and kernel basic information.lscpuβ‘ print processorβs information.export PS1="<\u@\h in \w >:"β‘ customize bash prompt to display<user1@server1 in /etc >:(seeman bash,PROMPTING).find . -name socket -o -name pipe -exec rm '{}' \;β‘ search for all files namesocketorpipeon current directory and remove all of them.find . -cmin 30β‘ search for all files modified on the past 30 min on current directory.find /usr -type f -atime +100 -size -5M -user rootβ‘ find all regular files accessed more than 100 days ago, not bigger tahn 5MB and owned byroot.
USE INPUT-OUTPUT REDIRECTION (>, Β», |, 2>, ETC.)
echo "lalala" > out.txtβ‘ redirect output, write it into the file.echo "lalala" >> out-hist.txtβ‘ redirect output, append it into the file.ls blah 2> error.txtβ‘ redirect error, write it into the file.ls blah 2>> error-hist.txtβ‘ redirect error, append it into the file.ls blah &> error-and-out.txtβ‘ redirect output and/or error, write it into the file.ls blah &>> error-and-out-hist.txtβ‘ redirect output and/or error, append it into the file.ls /usr/bin | grep manβ‘ redirect output, pipe it as the input for thegrepcommand.
USE GREP AND REGULAR EXPRESSIONS TO ANALYZE TEXT
grep -i path ~/.bashrcβ‘ read.bashrcfile and match all lines containing the word βpathβ, lower and upper case.ls -la /etc | grep "\.conf$"β‘ match all lines ending with β.confβ from the output of thels -la /etccommand.
ACCESS REMOTE SYSTEMS USING SSH
ssh user3@server20β‘ accessserver30asuser3via secure shell.ssh server20 nmcli c sβ‘ executenmcli c scommand onserver20.scp server20:/etc/chrony.conf /tmpβ‘ get file fromserver20.scp -r /etc/sysconfig server20:/tmpβ‘ transfer entire directory toserver20.rsync -avPzr /etc server20:/tmpβ‘ copy directory recursively toserver20, verbose mode, displaying progress, applying compression in transit.
LOG IN AND SWITCH USERS IN MULTIUSER TARGETS
su - user20β‘ switch into a new login session asuser20.
ARCHIVE, COMPRESS, UNPACK, AND UNCOMPRESS FILES USING TAR, STAR, GZIP, AND BZIP2
tar -czf etc-bkp.tar /etcβ‘ createetc-bkp.tarfile containing agzipcompressed archive of the/etcfolder.tar -cjf etc-bkp.tar /etcβ‘ same as above but compressed withbzip2.tar -xvf etc-bkp.tar -C new-etc/β‘ extract the file, verbose mode, into thenew-etc/directory.
CREATE AND EDIT TEXT FILES
touch newfile.txtβ‘ create empty new file.
CREATE, DELETE, COPY, AND MOVE FILES AND DIRECTORIES
mkdir -p myapp/db myapp/assets,mkdir -p myapp/{db,assets}β‘ createdbandassetsdirectories insidemyappdirectory, creatingmyappdir if it doesnβt exist.rm -rf myappβ‘ removemyappdirectory and its directories and files recursively.cp -r myapp/ newappβ‘ copy all the content frommyappdir intonewappdir.mv myapp/* newapp/β‘ move all the content frommyappdir intonewappdir.mv myapp newappβ‘ renamemyappdir tonewapp.
CREATE HARD AND SOFT LINKS
ln -s .dotfiles/.bashrc .bashrcβ‘ create a softlink named.bashrcthat links to.dotfiles/.bashrcfile.
LIST, SET, AND CHANGE STANDARD UGO/RWX PERMISSIONS
id user1β‘ print user and groups IDs foruser1.umask -S g-wx,o=wβ‘ same asumask 0035(whenumaskis set to0002). Sets umask temporarily, does not survive a reboot!To change umask permanently for all users (non system reserved uid/gids):
- Edit
umask 002line at both/etc/profileand/etc/bashrcfiles, applying the desired umask value.
- Edit
usermod -aG sgrp user1000β‘ appendsgrpas a suplementary group foruser1000.chmod 644 somefile.txtβ‘ set file permissions to u=rw,g=r,o=r.chmod +022 somefile.txtβ‘ add g=w,o=w permissions to the file.chmod ug+x,o-wβ‘ add user and group execute permission and remove write permission from others.chown root:sgrp /sdirβ‘ change ownership and owning group torootandsgrprespectively.chmod +4000 /usr/bin/su,chmod u+s /usr/bin/suβ‘ enablessetuidinsufile without touching other predefined permissions. (setuidis used to give special permissions on executable files)chmod +2000 /usr/bin/write,chmod g+s /usr/bin/writeβ‘ enablessetgidinwritefile without touching other predefined permissions.chmod +1000 /tmp,chmod o+t /tmpβ‘ sets the sticky bit on the specified directory without altering existing underlying permissions. (sticky bit on public and shared writable dirs are used to protect files and subdirs owned by normal users from being deleted or moved by other normal users.)
LOCATE, READ, AND USE SYSTEM DOCUMENTATION INCLUDING MAN, INFO, AND FILES IN /USR/SHARE/DOC
mandbβ‘ rebuild manual pages db. If you canβt find manual page results after issuing commands likeman,apropos,whatis, that means the manual pages db must be broken or inexistent and you should rebuild it.man 5 shadowβ‘ show man pages forSHADOW(5), the password file, not thepasswdcommand.apropos -a ext4 tunableβ‘ search man pages and descriptions for both keywords.man -f,whatisβ‘ show description for the parameter given.
Next:
(RHCSA) Create Simple Shell Scripts
β¦or back to Red Hat Certified System Administrator (RHCSA) Exam Study Guide
Useful links & references:
Enable Sysadmin (a blog from Red Hat)
Footnotes:
- Follow me on Twitter to get more posts like this and other quick tips in your feed.
- If you have any doubts or tips about this article, Iβd appreciate knowing and discussing it via email.
- Do you have any other Linux tips? Would you like to publish that in this blog? Please send an email to all drops.
- As English is not my native language, I apologize for the errors. Corrections are welcome.
- Contact: contact [@] alldrops [.] info.




