Linux Command Line
85 flashcards by MentisLibrary
Core commands, useful flags, pipes, permissions, and process control for anyone living in a terminal.
- Which command prints the current working directory?
- pwd
- Which command lists directory contents?
- ls
- Which command changes the current directory?
- cd
- Which command creates a directory?
- mkdir
- Which command removes files, and which flag removes directories recursively?
- rm; use rm -r for directories
- Which command copies files and directories?
- cp
- Which command moves or renames files?
- mv
- Which command shows the contents of a file?
- cat
- Which command views a file one screen at a time?
- less
- Which commands show the first or last lines of a file?
- head and tail
- Which command searches text with patterns?
- grep
- Which command finds files by name, type, or other attributes?
- find
- Which command shows disk space usage of filesystems?
- df
- Which command shows how much space files and directories use?
- du
- Which command displays running processes interactively?
- top (or htop)
- Which command lists processes non-interactively?
- ps
- Which command terminates a process by PID?
- kill
- Which command kills processes by name?
- pkill (or killall)
- What does the pipe operator | do?
- Sends the stdout of one command into the stdin of the next
- What do the > and >> redirection operators do?
- overwrites a file with stdout; >> appends stdout to a file
- How do you redirect stderr to the same place as stdout?
- Append 2>&1 (or use &> in bash)
- What does /dev/null do?
- Discards everything written to it
- Which command counts lines, words, and characters?
- wc
- Which command sorts lines of text?
- sort
- What does the uniq command do?
- Collapses adjacent duplicate lines
- Which command extracts columns from delimited text?
- cut
- What is awk used for?
- Pattern-driven text processing with fields, ideal for column-based data
- What is sed used for?
- Stream editing: substitutions and edits applied line by line
- Which command changes file permissions?
- chmod
- What does chmod 644 mean?
- Owner can read and write; group and others can only read