Command Line Basics Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the $ in the command line?

A

It is the prompt or command prompt

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

What is the command line?

A

A user interface that’s navigated by typing
A way to interact with the computer using text and keywords

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

The command for the current machine and user name

A

Windows 10
$ whoami
scratchnsniff\jesse agar

Cloud 9
$ whoami
Ec2-user

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

Where does just the command cd take you?
What’s the difference between root, home, and user’s home and how do you get to each place

A

Takes you to user’s home direction (not the home folder)
Same as going
$ cd ~

The directory contains everything.
/home/user (c9 takes you to user when going “home”)
Including the home directory. Every user has their own home directory that contains pictures, music, personal files etc.

Root
cd /

Home
cd /home

User’s Home
cd ~
or
cd

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

Show files in current directory

A

$ ls

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

Show hidden files and folders
Show only hidden files and folders

A

$ ls -a
$ls -d .*

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

Show longform info on files and folders
(Shows the following: file mode, number of links, owner name, group name, number of bytes in the file, abbreviated month, day-of-month file was last modified, hour file last modified, minute file last modified, and the pathname)

A

$ ls -l
l for long form
(l for lots of info)

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

Show longform info on files and folders but with size in kb, mb, and gb as needed rather than just bytes

A

$ ls -lh
h for Human readable

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

Show files and folders by size

A

$ ls -s
s for size

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

Show files and folders by date modified

A

$ ls -t

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

Show files and folders by reversed (of whatever other flags)

A

$ ls -r

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

Create a file or update it’s date.
How do you do multiple files?

A

$ touch
‘Touch’ a file in memory. Creates files. Updates their ‘modified date’.
For multiple files separate by space
$ touch index.html script.js style.css

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

Keyword for home directory
Keyword for root directory
Where are they relative to one another

A

~
/

/home/ec2-user
~ and cd bring you to ec2-user, not home, on C9

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

Keyword for previous directory

A

..

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

Keyword for current directory

A

.
Can be used as a shortcut to add everything in this directory:
$ git add .

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

Autocomplete a name in terminal
How does it behave if multiple files have the same common letters?

A

tab while typing a name
Will complete the directory or filename
It will autocomplete up to the most common letter among the options
If there are no more common letters but multiple options, press tab again and it will show you the options

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

Display name of the current directory

A

$ pwd

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

Rename a file

A

mv oldfile.txt newfilename.txt

Also how you move a file

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

Move a file

A

mv oldfiledirectory.txt newfiledirectory.txt

Also how you rename

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

Create a directory

A

$ mkdir

21
Q

Create nested directory

A

Create a series of nested directories
$ mkdir -p directory1/directory2

p for parent

22
Q

Create a directory in the previous directory

A

$ mkdir ../newdirectory

23
Q

Create directory and print the results of mkdir to console

A

$ mkdir -v for Verbose

24
Q

Copy a file

A

$ cp sourcefilename.txt directory/filename2.txt

25
Q

Copy files and prints results to console

A

$ cp -v

26
Q

Copy directory

A

$ cp -r

27
Q

Copy and force overwrite (not required for same user)

A

$ cp -f
Only needed when overwriting the file of another user

28
Q

Copy and prompt overwrite

A

$ cp -i
i for interactive

29
Q

Delete a file

A

$ rm

30
Q

Delete a directory

A

$ rm -r

31
Q

Chain commands, redirect the output of one command into another.

A

pipe operator
Ex:
ls -a ~ | grep _ | sed “s/_/-/g”
ls all files indirectory
Find files with _
Replace _ with -

32
Q

Write the output of a command to file

A

> ls -a ~ | grep _ > underscores.txt
Ex:
Listing 1.39: $ cat underscores.txt
.DS_Store
.bash_history
.bash_profile
.guard_history
.pry_history
.psql_history
.rediscli_history
.scala_history

33
Q

Read from file

A

<
Pipe that information from a file into a command

34
Q

Create an identical copy of a file that gets updated as the source file is updated.

What happens if source file gets deleted?

A

$ ln sourcefilename.txt targetnewfilename.txt
If source if deleted, target survives as independent file.

35
Q

Force a file to become the backup target of another

A

$ ln -f
ln sourcefilename.txt targetfilename.txt -f
Overwrites the existing file.

36
Q

Create an identical copy of a file on a different file system and for directories.

A

Symbolic copy
ln -s a.txt b.txt
Because it works for directories and different file systems, its much more common.

37
Q

Relative vs absolute path

A

If it starts from root (/) it’s absolute
starting from current location it’s relative.

38
Q

check node version

A

$ node -v

39
Q

install readline sync so you can have input in JS programs without a browser

A

$ npm install readline-sync –save

40
Q

Get the manual for a command

A

$ man (any command)

41
Q

sudo stands for…

A

superuser do
It’s the master key to your high-privilege admin tasks.

42
Q

Go 2 folders up, 3 folders up

A

cd ../..
cd ../../..

43
Q

List all files that follow a certain name pattern

A

use * to indicate any characters or number of characters

44
Q

Copy all the contents of a folder

A

cp folder/* folder2

45
Q

View a tree view of all folders from the current directory or specific direction

A

tree
tree folderName

46
Q

list only hidden files
what else does the command do?

A

ls -d .*

47
Q

what’s the difference between /foldername and foldername/

A

/foldername is looking at the root directory
foldername/ is looking from the current directory

48
Q

Find an executable’s location

A

which executable
ex:
which touch