4.0

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/70

encourage image

There's no tags or description

Looks like no tags are added yet.

71 Terms

1
New cards

first thing you always do

  • whoami

  • hostname

  • pwd


2
New cards

find directory, file size, who owns it, what group it belongs to

ls -l

3
New cards

delete a file

rm -f <file>

4
New cards

delete a directory

rm -r <dir>

5
New cards

create a directory

mkdir <name>

6
New cards

check options of a command

man <command>

7
New cards

3 types of file permissions

read, write, execute

8
New cards

each file permission can be controlled at 3 levels

user, group, other


9
New cards

command to change file permissions

chmod ugo+rwx

10
New cards

in file permissions first 3 bits, 2nd 3 bits, 3rd 3 bits

user, group, other

11
New cards

read a file

cat <file>

12
New cards

there are 2 owners of a file

user or group

13
New cards

change ownership of a file

chown <new-owner> <file>

14
New cards

change group ownership of a file

chgrp <new-group> <file>

15
New cards

log out of root

exit

16
New cards

what is an acl?

Access control list - flexible permision instead of u (every user) you can create an ACL for that specific user

17
New cards

show acl's

getfacl

18
New cards

use ACL to add permission for user

setfacl -m u:user:rwx /path/to/file

19
New cards

Add file permissions for a specific group

setfacl -m g:group:rwx /path/to/file

20
New cards

allow all files in an ACL to be cascading

setfacl -rm <u,g:name:rwx:> /path/to/dir

21
New cards

remove a specific acl entry

setfacl -x u:user:rwx

22
New cards

remove all acl entries from everyone

setfacl -b /path/to/file

23
New cards

3 types of help commands

  • whatis <command>

  • <command> --help

    • man <command>


24
New cards

use a help command

whatis <command>

man <command>

25
New cards

list all files that start with j

ls j<tab-key>

26
New cards

auto-complete commands

tab key

27
New cards

get all commands that start with

hit tab key TWICE

28
New cards

3 simple ways to add texts to files

  • vi

  • redirects » or <

  • echo


29
New cards

What is the difference between Chmod and setfacl

  • chmod only allows broad

  • Acl’s let you set specific file permissions


30
New cards

why do you do » instead of >

because if you only use > it’ll overwrite what you wrote

31
New cards

3 types of redirects in linux

  • standard input

  • standard output

    • error


32
New cards

file descriptor # stdin

0

33
New cards

file descriptor # stdout

1

34
New cards

stderr file descriptor #

2

35
New cards

the output of a command can be routed to a file using

>

36
New cards

route the output of ls -l to a file

ls -l > file

37
New cards

view hidden files

ls -la

38
New cards

when a command is executed on the keyboard

stdin - 0

39
New cards

when a command is displayed on the screen

stdout - 1

40
New cards

if a command showed an error message

stder - 2

41
New cards

Tee command is used to

store and output at the same time (it’s like saving a redirect »)

42
New cards

why do you do | tee -a

-a = append → same thing as » vs >

43
New cards

tee command syntax

ls -l | tee -a

44
New cards

find how many characters you have in a file

wc -c <file>

45
New cards

use a pipe command

ls -l | more

46
New cards

view the end of a command output

ls -l | tail

47
New cards

view output one page at a time

ll | more

48
New cards

execute multiple commands

ls ; cd ; pwd

49
New cards

copy a file

cp <source> <new-name>

50
New cards

copy a file but move it to a different location

cp <file> /path/to/dir

51
New cards

remove a file

rm <file>

52
New cards

rename a file

mv <source> <new-name>

53
New cards

move a files location

mv <source> /path/to

54
New cards

create a directory

mkdir <name

55
New cards

delete a directory

rmdir <name>

56
New cards

remove a directory without using rmdir

rm -Rf <name>

57
New cards

change group owner of a file

chgrp <newowner> <file>

58
New cards

change the file owner

chown <new-owner> <file>

59
New cards

change owner/group of a file in one command line

chown <owner>:<group> file

60
New cards

read one page at a time

more <file>

61
New cards

get prompt back when using more command

q

62
New cards

read a file one line at a time

less <file>

63
New cards

What is the difference between the more command and less command

  • more = one page at a time

  • less = one line at a time


64
New cards

view the end of a file

tail -2 <file>

65
New cards

view the top of a file

head -2 <file>

66
New cards

get the first character of each line in a file

cut -c1 <file>

67
New cards

get a range of characters out of a file

cut -c1-3 <file>

68
New cards

get multiple ranges of characters out of a file

cut -c1-3, 6-8 <file>

69
New cards

what is a delimiter

what seperates lines like → :

70
New cards

where is the delimiter in cut -d: -f # <file>

What does -f stand for?

  • delimiter → :

    • -f stands for field


71
New cards

get characters out of a file by specifying the delimiter

  • cut -d: -f # <file>