Introduction | Command Line Flashcards
The command line is a text interface for your computer. It’s a program that takes in commands, which it passes on to the computer’s operating system to run.
pwd prints the name of the working directory
cd takes a directory name as an argument, and switches into that directory
ls lists all files and directories in the working directory
cp copies files or directories.
cp file1 file2 will copy file1 to file2
To move up one directory, use
mkdir takes in a directory name as an argument, and then creates a new directory in the current working directory.
To move a file into a directory, use
mv with the source file as the first argument and the destination directory as the second argument
cat allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.
touch creates a new file inside the working directory. It takes in a file name as an argument, and then creates a new empty file in the current working directory. Here we used touch to create a new file named keyboard.txt inside the 2014/dec/ directory.
grep stands for “global regular expression print”. It searches files for lines that match a pattern and returns the results. It is case sensitive.
rm deletes files
rm -r removes a directory recursively
man command shows the manual for the specified
chmod ugo file changes permissions of file to ugo - u is the user's permissions, g is the group's permissions, and o is everyone else's permissions. The values of u, g, and o can be any number between 0 and 7.
cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files.
>> takes the standard output of the command on the left and appends (adds) it to the file on the right. Example:
cat glaciers.txt >> rivers.txt
< takes the standard input from the file on the right and inputs it into the program on the left. Example:
cat < lakes.txt
| 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. Example:
cat volcanoes.txt | wc