Linux Commands Flashcards

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
Q

$ ls -t

A

Sorts the content of the working directory by modification time.

26
Q

$ file name_of_file

A

The file command will print a brief description of the file’s (name_of_file) contents.

27
Q

$ less name_of_file

A

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
Q

$ 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).

A

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
Q

What is the copy-and -paste trick when using a mouse?

A

If you are using a mouse, you can double-click a filename to copy it and middle-click to paste it into commands.

30
Q

What is the meaing of this wildcard: *

A
  • Matches any characters
31
Q

What is the meaning of this wildcard: ?

A

? Matches any single character

32
Q

What is the meaning of this wildcard: [characters]

A

[characters] Matches any character that is a member of the set characters

33
Q

What is the meaning of this wildcard: [!characters]

A

[!characters] Matches any charachter that is not a member of the set characters

34
Q

What is the meaning of this wildcard: [[:class:]]

A

[[:class:]] Matches any character that is a member of the specified class

35
Q

Name commonly used character classes

A

[: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
Q

How can you select all files of a directory?

A

*

37
Q

How can you select any file beginning with “ g “?

A

g*

38
Q

How can you select any file beginning with “ b “ followed by any characters and ending with “ .text “ ?

A

b*.txt

39
Q

How can you select any file beginning with either “ a “, or “ b “, or “ c “ ?

A

[abc]*

40
Q

How can you select any file beginning with “ Data “ followed by exactly three characters?

A

Data???

41
Q

How can you select any file beginning with “ BACKUP. “ followed by exactly three numerals?

A

BACKUP. [0-9][0-9][0-9]

42
Q

How can you select any file beginning with an uppercase letter?

A

[[:upper:]]*

43
Q

How can you select any file beginning with a numeral?

A

[![:digit:]]*

44
Q

How can you select any file ending with a lowercase letter or the numerals 1, 2, or 3?

A

*[[:lower:]123]

45
Q

How can you create a directory?

A

$ mkdir name_of _directory

46
Q

How can you create three directories named dir1, dir2, dir3?

A

$ mkdir dir1 dir2 dir3

47
Q

How can you copy the single file or directory “item1” to the file or directory “item2”?

A

$ cp item1 item2

48
Q

How can you copy “item1”, “item2” and “item3” to the directory “dir1” ?

A

$ cp item1 item2 item 3 dir1