Command Line Flashcards
What does the command ‘ls’ do?
Lists the files in a directory
What command id used to find out the directory you are currently in?
pwd
What is the command to create an empty file
touch
What does using the -a flag with ls do?
Shows all files including those which start with a ‘.’ and therefore are hidden
What does using the -t flag with ls do?
Shows all files in a directory in order of most recently modified
What does using the -l flag with ls do?
Shows all files in a directory in the long format.
Here there are four rows, with seven columns separated by spaces. Here’s what each column means:
- Access rights. These are actions that are permitted on a file or directory.
- Number of hard links. This number counts the number of child directories and files. This number includes the parent.
- The username of the file’s owner. Here the username is cc.
- The name of the group that owns the file. Here the group name is eng.
- The size of the file in bytes.
- The date & time that the file was last modified.
- The name of the file or directory. directory link (..) and current directory link (.).
What is the wildcard special character
*
What command can be used to rename a file?
mv
What is the stdin, stdout and stderr?
stdin - standard input, is information inputted into the terminal through the keyboard or input device.
stdout - standard output, is the information outputted after a process is run.
stderr - standard error, is an error message outputted by a failed process.
What is the command for seeing the content of a file?
cat
What is the command for redirecting the standard input to standard output?
>
What command is used to append standard input to standard output without overwriting?
> >
What does the < command do?
e.g. $ cat < lakes.txt
< takes the standard input from the file on the right and inputs it into the program on the left. Here, lakes.txt is the standard input for the cat command. The standard output appears in the terminal.
What is ‘|’ and what is it used for?
e.g.
$ cat volcanoes.txt | wc | cat > islands.txt
Here the output of cat volcanoes.txt is the standard input of wc. in turn, the wc command outputs the number of lines, words, and characters in volcanoes.txt, respectively.
is a “pipe”. The | takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as “command to command” redirection.
What command can be used to take the standard input and sort alphabetically?
sort