Linux Commands Flashcards

(48 cards)

1
Q

$ exit

A

closes the terminal emulator window

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

$ date

A

displays the current time and date

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

$ cal

A

displays a calender of the current month

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

$ pwd

A

prints full path of current working directory

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

$ cd

A

changes directory (to root without giving pathname)

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

$ ls

A

lists directory content

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

$ cd /some/path/name

$ cd ~/some/path/name

A

changes directory by given absolut path, which starts with the root “/” or with ~ as representation of the root followed by some directories

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

.

..

A

one dot represents the current working directory

two dots represent the parent directory of the current working directory

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

2. realtive pathname

A
  1. an absolute pathname starts from the root directory /
  2. a relative pathname starts from the working directory . /
    In almost all cases, we can omit the ./ part because it is implied because ./ means the working directory, but we start a relative part always from the working directory. Simply wrinting “ cd name_of_subdirectory” is enough.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you see hidden files?

A

Filenames that begin with a period character are hidden. This means that “ls” will not list them unless you enter “ls -a”.

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

How should filenames be written in Linux?

A

Filenames and commands in Linux are case sensitive. Most important, do not embed spaces in filenames. If you want to represent spaces between words in a filename, use underscore characters. File extensions are not necessary.

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

$ cd -

A

changes the working directory to the previous working directory

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

$ cd ~user_name

A

changes the working directory to the home directory of user_name

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

$ ls

A

lists content of working directory

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

$ ls /some/path/name

A

lists the content of the directory, specified by this pathname, without changing the current working directory

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

$ ls -l

A

lists the content in long detailed form of the working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  1. $ ls -lt

2. $ ls -lt –reverse

A
  1. lists the content in long detailed form “-l” and sorts the content by the modification time “-t” of the current working directory
  2. reverses the order of the sorted content
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

$ ls -a (–all)

A

lists all files, even those with names that begin with a period, which are normally not listed (that is, hidden)

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

$ ls -A (–almost-all)

A

lists like the -a option hidden files except it does not list .(current directory) and ..(parent directory)

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

$ ls -d (–directory)

A

Ordinarily, if a directory is specified, ls will list the contents of the directory, not the directory itself. Use this option in conjunction with the -l option to see details about the directory rather than its contents.

21
Q

$ ls -F (–classify)

A

This option will append an indicator character to the end of each listed name. For example, it will append a forward slash (/) if the name is a directory.

22
Q

$ ls -h (–human readable)

A

In long format listings (in combination with -l), displays file sizes in human-readable format rather than in bytes.

23
Q

$ ls -r (–reverse)

A

Displays the content of the working directory in reverse order. Normally, ls displays its results in ascending alphabetical order.

24
Q

$ ls -S

A

Sorts the content of the working directory by file size.

25
$ ls -t
Sorts the content of the working directory by modification time.
26
$ file name_of_file
The file command will print a brief description of the file's (name_of_file) contents.
27
$ less name_of_file
The less command is a program to view text files, like configuration files, program-scripts, etc. If we accidently attempt to view a non-text file and it scrambles the terminal window, we can recover by entering the "reset" command.
28
$ less name_of _file Name typical less commands, that can be used once the less programm starts and enables the view of the content of the file (name_of_file).
PAGE UP or b Scroll back one page PAGE DOWN or space Scroll forward one page Up arrow Scroll up one line Down arrow Scroll down one line G Move to the end of the text file 1G or g Move to the beginning of the text file /characters Search forward to the next occurrence of characters n Search for the next occurrence of the previous search h Display help sreen q Quit less
29
What is the copy-and -paste trick when using a mouse?
If you are using a mouse, you can double-click a filename to copy it and middle-click to paste it into commands.
30
What is the meaing of this wildcard: *
* Matches any characters
31
What is the meaning of this wildcard: ?
? Matches any single character
32
What is the meaning of this wildcard: [characters]
[characters] Matches any character that is a member of the set characters
33
What is the meaning of this wildcard: [!characters]
[!characters] Matches any charachter that is not a member of the set characters
34
What is the meaning of this wildcard: [[:class:]]
[[:class:]] Matches any character that is a member of the specified class
35
Name commonly used character classes
[:alnm:] Matches any alphanumerical character [: alpa:] Matches any alphabetic character [:digit:] Matches any numeral [:lower:] Matches any lower case letter [:upper:] Matches any uppercase letter
36
How can you select all files of a directory?
*
37
How can you select any file beginning with " g "?
g*
38
How can you select any file beginning with " b " followed by any characters and ending with " .text " ?
b*.txt
39
How can you select any file beginning with either " a ", or " b ", or " c " ?
[abc]*
40
How can you select any file beginning with " Data " followed by exactly three characters?
Data???
41
How can you select any file beginning with " BACKUP. " followed by exactly three numerals?
BACKUP. [0-9][0-9][0-9]
42
How can you select any file beginning with an uppercase letter?
[[:upper:]]*
43
How can you select any file beginning with a numeral?
[![:digit:]]*
44
How can you select any file ending with a lowercase letter or the numerals 1, 2, or 3?
*[[:lower:]123]
45
How can you create a directory?
$ mkdir name_of _directory
46
How can you create three directories named dir1, dir2, dir3?
$ mkdir dir1 dir2 dir3
47
How can you copy the single file or directory "item1" to the file or directory "item2"?
$ cp item1 item2
48
How can you copy "item1", "item2" and "item3" to the directory "dir1" ?
$ cp item1 item2 item 3 dir1