linux programming Flashcards

1
Q

list

A

ls

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

what are hidden files in ls

A

beginning with dot

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

list + show hidden files

A

ls -a

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

show username

A

whoami

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

make directory

A

mkdir directory

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

change directory

A

cd

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

go back (or up) one directory (switch to parent directory)

A

cd ..

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

current directory

A

cd .

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

get absolute pathname

A

pwd (print workind directory) - shows all parent directories

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

what 3 parts is unix made up of

A

kernel, shell and programs

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

what does the kernel of UNIX do?

A

The kernel of UNIX is the heart of the operating system. It
- allocates time and memory to programs and
- handles the file store and
- handles communications in response to system calls.

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

Illustration of how the shell and kernel work together

A
  • User types rm file
  • shell searches for filestore containing program rm
  • requests kernel, through system calls, to execute rm on file.
  • when rm file completes, system returns $ awaiting further commands
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

the shell in UNIX

A

acts as an interface between the user and kernel. The shell is a command line interpreter that allows users to type commands (or ā€˜talkā€™ to the kernel).

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

create empty file

A

touch fileName.filetype

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

move a file

A

mv (file to be moved) (move to this directory)

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

copy a file

A

cp (originalFile.filetype) (newFile.filetype)

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

remove file and directory

A

rm and rmdir but rmdir will only remove an empty directory

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

display contents of a file

A

cat (concatenate)

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

display first 10 lines in a file

A

head file.filetype

20
Q

display first 5 lines in a file

A

head -5 file.filetype

21
Q

write last 10 lines

A

tail file.filetype

22
Q

grab word from a file

A

grep word file.
- remember is case sensitive

23
Q

grep ignore cases

A

grep -i Science science.txt

24
Q

other grep commands

A

-v show all not containing science
-n precede each instance with the line number
-c show count of matched lines

25
Q

word count

A

wc
-c , prints byte count
-l, prints line count
-w, prints word count

26
Q

exit entering

A

cntrl D

27
Q

redirect output to a file

A

cat > file
- from here, enter input to file ie
pear
banana
apple
- this creates a file called list1 containing words pear, banana and apple

28
Q

append to a file

A

cat&raquo_space; list1
- type to add to file

29
Q

concat two files together

A

cat list1 list2 > bigList

30
Q

sort file

A

sort < file

31
Q

assign sorted file to new file

A

sort < file > sortedFile

32
Q

get who is on the system with you and assign to a text file
then sort them

A

who > names.txt
sort < names.txt
problematic as names.txt has to be deleted afterwards
shorthand - who | sort

33
Q

see who is on the system with you

A

who

34
Q

shorthand for viewing and sorting names of those on system

A

who | sort

35
Q

view number of who

A

who | wc -l

36
Q

using pipes, display all lines of list1 and list2 containing the letter ā€˜pā€™

A

cat list1 list2 | grep p | sort

37
Q

wildcards

A
  • and ?
38
Q

when not sure of the name of the command

A

apropos
eg. apropos copy will display commands with copy in their manual page header

39
Q

access rights

A

ls -l
- access rights at left hand side of first line. if starts with d, directory
- left group owners
- middle group belongs
- right group everyone else

40
Q

changing a file mode and options

A

(changing permissions)
chmod
u - user
g - group
o - others
r - read
w - write (and delete)
x - execute (and access directory)
+ add permission
- take away permission

41
Q

see info about processes

A

ps

42
Q

run sleep and run sleep in background

A

(sleep for 10 secs) sleep 10
(sleep for 10 secs in background) sleep 10 &

43
Q

suspend process running in foreground, then put it in backgtound

A

control z (suspends process)
bg (puts in background)

44
Q

view running processes and restart a suspended process

A

jobs (view)
fg jobnumber (restart job)

45
Q

kill a process in the foreground

A

cntrl c

46
Q

kill a process in the background

A

kill %jobnumber

47
Q

report space left on system

A

df