Linux Command Line Fundamentals
Comprehensive quiz covering essential Linux command line commands and concepts including file operations, process management, text processing, permissions, wildcards, and path navigation.
Questions
Shutdown the system. (Replace -h with -r for reboot.)
- shutdown -h now
- find /home -mtime -1
- df -h
- du -sh ./*
Find all files in the given directory (and subs) which have been modified in the last 24 hours.
- basename -s .jpg -a *.jpg | xargs -n1 -i cp {}.jpg {}_bk.jpg
- find /home -mtime -1
- du -sh ./*
- df -h
Make a copy of every jpg image file in the current directory and rename adding _bk
- basename -s .jpg -a *.jpg | xargs -n1 -i cp {}.jpg {}_bk.jpg
- find /home -mtime -1
- du -sh ./*
- shutdown -h now
Display how much disk space is used and also free.
- df -h
- du -sh ./*
- find /home -mtime -1
- shutdown -h now
Find the size of every directory in your current directory.
- du -sh ./*
- df -h
- basename -s .jpg -a *.jpg | xargs -n1 -i cp {}.jpg {}_bk.jpg
- find /home -mtime -1
Move the given process from the background to the foreground
- fg <job number>
- bg <job number>
- kill <process id>
- killall <process name>
See a list of current processes in the background.
- jobs
- ps
- tree
- pstree
Pause the currently running process and put it in the background.
- CTRL + Z
- CTRL + C
- CTRL + D
- CTRL + R
Obtain a listing of processes and their id's. Including the option aux will show all processes.
- ps
- jobs
- pwd
- tree
Cancel the given process. Include the option -9 to kill a stubborn process.
- kill <process id>
- fg <job number>
- bg <job number>
- jobs
Cancel the currently running process.
- CTRL + C
- kill <process id>
- CTRL + Z
- CTRL + D
Feed the STDOUT of the program on the left as STDIN to the program on the right.
- |
- <
- >
- <>
Pass the contents of a file to a program as STDIN.
- <
- 2>
- |
- ||
Redirect the STDERR to a file.
- 2>
- >>
- >
- |
Append STDOUT to the end of a file.
- >>
- >
- 2>
- |
Redirect STDOUT to a file.
- >
- >>
- 2>
- <
Search for a given pattern.
- grep
- wc
- sort
- tree
How many words, characters and lines
- wc
- grep
- how
- try
Sort lines in a given way.
- sort
- wc
- grep
- ord
Show the last n lines.
- tail
- head
- wc
- grep
Show the first n lines.
- head
- tail
- sort
- wc
Change permissions. Permissions can be either shorthand (eg. 754) or longhand (eg. g+x).
- chmod <permissions> <path>
- chown <permissions> <path>
- chperm <permissions> <path>
- chinge <permissions> <path>
View the permissions of a file or all items in a directory.
- ls -l [path]
- ls [path]
- dir [path]
- dir -l [path]
--x
- execute
- read
- write
- nothing
-w-
- write
- read
- execute
- nothing
r--
- read
- write
- execute
- nothing
Range
- [ ]
- *
- ?
- .
Single character
- ?
- *
- .
- [ ]
Zero or more characters
- *
- ?
- [ ]
- .
Remove a file or directory. Common options: -r -f
- rm <path>
- del <path>
- remove <path>
- delete <path>
Move the source file to the destination. May also be used to rename files or directories.
- mv <source> <destination>
- cp <source> <destination>
- ren <source> <destination>
- move <source> <destination>
Copy the source file to the destination.
- cp <source> <destination>
- mv <source> <destination>
- copy <source> <destination>
- ls <source> <destination>
Create a blank file.
- touch <file name>
- rm <path>
- mkdir <directory name>
- rmdir <directory name>
Remove a directory (only if empty).
- rmdir <directory name>
- mkdir <directory name>
- touch <file name>
- rm <path>
Create a directory
- mkdir <directory name>
- rmdir <directory name>
- touch <file name>
- rm <path>
Search for man pages containing the search term.
- man -k <search term>
- man -s <search term>
- man -r <search term>
- man -l <search term>
View the man page for a command.
- man <command>
- man -k <command>
- man -r <command>
- man -s <command>
Find out what type of item a file or directory is.
- file [path]
- ls [path]
- cd [path]
- pwd
Start typing and press SOME KEY. The system will auto complete the path.
- TAB
- ESC
- SPACE
- NUM LOCK
Used in paths as a reference to your current directories parent directory.
- .. (dot dot)
- . (dot)
- ~ (tilde)
- cd [path]
Used in paths as a reference to your current directory.
- . (dot)
- .. (dot dot)
- ~ (tilde)
- pwd
Used in paths as a reference to your home directory.
- ~ (tilde)
- . (dot)
- .. (dot dot)
- cd [path]
One relative to where you currently are in the system (eg. Documents/music ).
- Relative Path
- Absolute Path
- ~ (tilde)
- . (dot)
One beginning from the root of the file system (eg. /etc/sysconfig ).
- Absolute Path
- Relative Path
- pwd
- . (dot)
A description of where a file or directory is on the filesystem.
- Path
- pwd
- ~ (tilde)
- cd [path]
Change into the given path or into your home directory.
- cd [path]
- ls [path]
- pwd
- .. (dot dot)
Perform a listing of the given path or your current directory. Common options: -l, -h, -a
- ls [path]
- pwd
- cd [path]
- file [path]
Where am I in the system.
- pwd
- cd
- ~ (tilde)
- .. (dot dot)