List out all files in the /etc directory that end with the extension .conf.
Save the list of successful matches to a file named /tmp/found_files.txt.
Redirect all "Permission Denied" errors to a separate file named /tmp/errors.log.
Verify the total count of files found by using the wc command with input redirection from /tmp/found_files.txt.
Solution
Direct to root directory and open etc folder
cd /etc
List down all file end with .conf
ls *.conf
Save the list to /tmp/found_files.txt
ls *.conf>/tmp/found_files.txt
Save the error to /tmp/errors.log
ls *.conf 2> /tmp/errors.log
Verify
wc -l < found_files.txt
wc -1 < errors.log
Create a directory named /tmp/archive.
Inside that directory, create 12 empty files named backup_1.tar.gz through backup_12.tar.gz using a single command.
Use a single command to list only the files for the first three files (1,2,3).
Create a file named system_info.txt that contains the current hostname of the machine followed by the current date, using command substitution. Exp: localhost.localdomain 2026-03-26
Solution
Direct to root directory and open tmpfolder
cd /tmp
Create and open directory
mkdir archive
cd archive
Create log file
touch backup_{1..12}.tar.gz
List first quarter file
ls backup_{1..3}.tar.gz
Create file
echo "$(hostname) $(date +%Y-%m-%d)" > system_info.txt
Verify file content
cat system_info.txt
Create an alias named grep_etc that executes grep -i "root" /etc/passwd.
Ensure this alias is available every time you log in as your current user.
Define a global environment variable named PROJECT_DIR with the value /var/projects.
Ensure this variable is exported automatically for all sub-shells.
Apply immediately in current session.
Validation: Log out, log back in, and verify the alias and variable still work.
Solution
Direct to home directory
cd ~
Open .bashrc by using vim editor
vim .bashrc
Press Esc to make sure in Normal Mode.
Press I to enter insert mode and Enter to make sure in new line.
Create alias
alias grep_etc='grep -i "root" /etc/passwd'
Create global variable
export PROJECT_DIR='/var/projects'
Press Esc to make sure in Normal Mode.
Save and exit
:wq --> Enter
Apply immediately in current session.
source .bashrc
Close terminal, log out and log in RHEL, open terminal
Verify alias
grep_etc
Open another session
bash
There's no new terminal will show up.
Check current level
echo $SHLVL
It will return 2, means at we at shell level 2, because open new session by using bash.
Verify variable
echo $PROJECT_DIR
Locate the line number in your history for the last touch command you ran.
Execute that command again using its history index number.
Delete only that specific entry from your history list.
Force all history to be written to the .bash_history file immediately.
Solution
Search touch command in the history
history | grep touch
Execute specific index
![Command Index]
Exp: !22
Delete the specific command in history
history -d [Command Index]
Exp: history -d 22
Save current session history
history -w
Direct to home directory
cd ~
Find location of .bash_history
find .bash_history
Seems it is a hidden file in home directory, display all file
ls -a
Verify file content
cat .bash_history