Outcome 2 Study Questions Flashcards
(48 cards)
What command would you use to determine the absolute path of the current directory you are in?
pwd – Prints the absolute path of the current directory.
List the command to display all files and directories inside /bin in long format.
ls -l /bin – Lists all files in /bin with details.
How would you find out where the ls command is located on the system?
which ls or whereis ls – Shows the location of the ls command.
Write the command to display the kernel version of the current Linux system.
uname -r – Displays the Linux kernel version.
What does the following command do?
ls /dev | grep tty
ls /dev | grep tty – Lists all device files containing “tty” in their name.
Which command allows you to view a paginated list of files within the /etc directory?
ls -l /etc | less
Issue the command to create the following directory structure in one line:
/home/user/labs/test1/test2/test3
mkdir -p /home/user/labs/test1/test2/test3
How do you create an empty file called testfile.txt in your current directory?
touch testfile.txt
Write the command to copy testfile.txt from your home directory to /var/tmp/.
cp ~/testfile.txt /var/tmp/
How would you rename testfile.txt to logfile.log?
mv testfile.txt logfile.log
What command would you use to delete a non-empty directory called old_projects?
rm -rf old_projects
Write the command to move logfile.log to a directory called logs.
mv logfile.log logs/
What are the default file permissions for a newly created file in Linux?
rw-r–r– (644)
Issue the command to modify the permissions of script.sh to be executable only by the owner.
chmod 700 script.sh
Write the octal equivalent of rwxr-x— file permission.
750
Change ownership of project.doc to the user john and group developers.
chown john:developers project.doc
How do you recursively change the permissions of all files inside a directory called docs to 644?
chmod -R 644 docs/
What command would you use to view detailed permission information of a file named config.conf?
ls -l config.conf
Which command allows you to view the last 10 lines of a file called error.log in real-time?
tail -f error.log
Write the command to search for all occurrences of the word “error” inside the file system.log.
grep “error” system.log
How would you display only the first 5 lines of a file called data.csv?
head -5 data.csv
Find all .txt files within /var/logs/ that contain the word “critical”.
grep -rl “critical” /var/logs/*.txt
Using grep, write the command to search for lines that do NOT contain the word “debug” in logfile.txt.
grep -v “debug” logfile.txt
What does the following command do?
ls /etc | grep -E ‘^p’
Lists all files and directories in /etc that start with the letter “p”.