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 bash
then/^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
vimtutor
in 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 namesocket
orpipe
on 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 thegrep
command.
USE GREP AND REGULAR EXPRESSIONS TO ANALYZE TEXT
grep -i path ~/.bashrc
ā” read.bashrc
file 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 /etc
command.
ACCESS REMOTE SYSTEMS USING SSH
ssh user3@server20
ā” accessserver30
asuser3
via secure shell.ssh server20 nmcli c s
ā” executenmcli c s
command 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.tar
file containing agzip
compressed archive of the/etc
folder.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}
ā” createdb
andassets
directories insidemyapp
directory, creatingmyapp
dir if it doesn’t exist.rm -rf myapp
ā” removemyapp
directory and its directories and files recursively.cp -r myapp/ newapp
ā” copy all the content frommyapp
dir intonewapp
dir.mv myapp/* newapp/
ā” move all the content frommyapp
dir intonewapp
dir.mv myapp newapp
ā” renamemyapp
dir tonewapp
.
CREATE HARD AND SOFT LINKS
ln -s .dotfiles/.bashrc .bashrc
ā” create a softlink named.bashrc
that links to.dotfiles/.bashrc
file.
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
(whenumask
is set to0002
). Sets umask temporarily, does not survive a reboot!To change umask permanently for all users (non system reserved uid/gids):
- Edit
umask 002
line at both/etc/profile
and/etc/bashrc
files, applying the desired umask value.
- Edit
usermod -aG sgrp user1000
ā” appendsgrp
as 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 toroot
andsgrp
respectively.chmod +4000 /usr/bin/su
,chmod u+s /usr/bin/su
ā” enablessetuid
insu
file without touching other predefined permissions. (setuid
is used to give special permissions on executable files)chmod +2000 /usr/bin/write
,chmod g+s /usr/bin/write
ā” enablessetgid
inwrite
file 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 thepasswd
command.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.