Codecademy Terminal Commands Flashcards

1
Q

>

A

$ cat oceans.txt > continents.txt

takes the standard output of the command on the left, and redirects it to the file on the right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

>

A

$ cat oceans.txt > continents.txt

takes the standard output of the command on the left, and redirects it to the file on the right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

> >

A

$ cat glaciers.txt&raquo_space; rivers.txt

> > takes the standard output of the command on the left and appends (adds) it to the file on the right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

|

A

$ cat volcanoes.txt | wc

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

~/.bash_profile

A

$ nano ~/.bash_profile

~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

alias

A

alias pd=”pwd”

The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A

$ cat < lakes.txt

< takes the standard input from the file on the right and inputs it into the program on the left.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

|

A

$ cat volcanoes.txt | wc

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

~/.BASH_PROFILE

A

$ nano ~/.bash_profile

~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ALIAS

A

alias pd=”pwd”

The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

env | grep VARIABLE

A

env | grep PATH

env | grep PATH is a command that displays the value of a single environment variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

cp

A

$ cp ada_lovelace.txt historical/

cp copies files or directories. Here, we copy the file ada_lovelace.txt and place it in the historical/ directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

*

A

$ cp * satire/

The wildcard * selects all of the files in the current directory. The above example will copy all of the files in the current directory to the directory called satire. There are other types of wildcards, too, which are beyond the scope of this glossary.

$ cp m*.txt scifi/

Here, m*.txt selects all files in the working directory starting with “m” and ending with “.txt”, and copies them to scifi/.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

env

A

The env command stands for “environment”, and returns a list of the environment variables for the current user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ENV | GREP VARIABLE

A

env | grep PATH

env | grep PATH is a command that displays the value of a single environment variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

export

A

export USER=”Jane Doe”

export makes the variable to be available to all child sessions initiated from the session you are in. This is a way to make the variable persist across programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

grep

A

$ grep “Mount” mountains.txt

grep stands for “global regular expression print”. It searches files for lines that match a pattern and returns the results. It is case sensitive.

18
Q

grep -i

A

$ grep -i “Mount” mountains.txt

grep -i enables the command to be case insensitive.

19
Q

grep -R

A

$ grep -R Arctic /home/ccuser/workspace/geography

grep -R searches all files in a directory and outputs filenames and lines containing matched results. -R stands for “recursive”.

20
Q

grep -Rl

A

grep -Rl Arctic /home/ccuser/workspace/geography

grep -Rl searches all files in a directory and outputs only filenames with matched results. -R stands for “recursive” and l stands for “files with matches”.

21
Q

HOME

A

$ echo $HOME

The HOME variable is an environment variable that displays the path of the home directory.

22
Q

ls

A

$ ls
2014 2015 hardware.txt

ls lists all files and directories in the working directory

23
Q

ls -a

A

ls -a
. .. .preferences action drama comedy genres.xt

ls -a lists all contents in the working directory, including hidden files and directories

24
Q

ls -l

A

ls -l
drwxr-xr-x 5 cc eng 4096 Jun 24 16:51 action
drwxr-xr-x 4 cc eng 4096 Jun 24 16:51 comedy
drwxr-xr-x 6 cc eng 4096 Jun 24 16:51 drama
-rw-r–r– 1 cc eng 0 Jun 24 16:51 genres.txt

ls -l lists all contents of a directory in long format.

25
Q

ls -t

A

ls -t orders files and directories by the time they were last modified.

26
Q

pwd

A

$ pwd
/home/ccuser/workspace/blog

pwd prints the name of the working directory

27
Q

mv

A

$ mv superman.txt superhero/

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. Here we move superman.txt into superhero/.

28
Q

nano

A

$ nano hello.txt

nano is a command line text editor. It works just like a desktop text editor like TextEdit or Notepad, except that it is accessible from the the command line and only accepts keyboard input.

29
Q

PATH

A

$ echo $PATH

/home/ccuser/.gem/ruby/2.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin

PATH is an environment variable that stores a list of directories separated by a colon. Each directory contains scripts for the command line to execute. PATH lists which directories contain scripts.

30
Q

pwd

A

$ pwd
/home/ccuser/workspace/blog

pwd prints the name of the working directory

31
Q

rm

A

$ rm waterboy.txt

rm deletes files. Here we remove the file waterboy.txt from the file system.

32
Q

rm -r

A

$ rm -r comedy

rm -r deletes a directory and all of its child directories.

33
Q

sed

A

$ sed ‘s/snow/rain/’ forests.txt

sed stands for “stream editor”. It accepts standard input and modifies it based on an expression, before displaying it as output data.

In the expression ‘s/snow/rain/’:

s: stands for “substitution”.
snow: the search string, the text to find.
rain: the replacement string, the text to add in place.

34
Q

sort

A

$ sort lakes.txt

sort takes a filename or standard input and orders each line alphabetically, printing it to standard output.

35
Q

standard error

A

standard error, abbreviated as stderr, is an error message outputted by a failed process.

36
Q

uniq

A

$ uniq lakes.txt

uniq, short for “unique”, takes a filename or standard input and prints out every line, removing any exact duplicates.

37
Q

stdin

A

standard input, abbreviated as stdin, is information inputted into the terminal through the keyboard or input device.

38
Q

stdout

A

standard output, abbreviated as stdout, is the information outputted after a process is run.

39
Q

touch

A

$ touch data.txt

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.

If the file exists, touch is used to update the modification time of the file

40
Q

uniq

A

$ uniq lakes.txt

uniq, short for “unique”, takes a filename or standard input and prints out every line, removing any exact duplicates.

41
Q

cat

A

The most common use of cat is to read the contents of files, and cat is often the most convenient program for this purpose. All that is necessary to open a text file for viewing on the display monitor is to type the word cat followed by a space and the name of the file and then press the ENTER key. For example, the following will display the contents of a file named file1:

cat file1