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
word count
wc -c , prints byte count -l, prints line count -w, prints word count
26
exit entering
cntrl D
27
redirect output to a file
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
append to a file
cat >> list1 - type to add to file
29
concat two files together
cat list1 list2 > bigList
30
sort file
sort < file
31
assign sorted file to new file
sort < file > sortedFile
32
get who is on the system with you and assign to a text file then sort them
who > names.txt sort < names.txt problematic as names.txt has to be deleted afterwards shorthand - who | sort
33
see who is on the system with you
who
34
shorthand for viewing and sorting names of those on system
who | sort
35
view number of who
who | wc -l
36
using pipes, display all lines of list1 and list2 containing the letter 'p'
cat list1 list2 | grep p | sort
37
wildcards
* and ?
38
when not sure of the name of the command
apropos eg. apropos copy will display commands with copy in their manual page header
39
access rights
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
changing a file mode and options
(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
see info about processes
ps
42
run sleep and run sleep in background
(sleep for 10 secs) sleep 10 (sleep for 10 secs in background) sleep 10 &
43
suspend process running in foreground, then put it in backgtound
control z (suspends process) bg (puts in background)
44
view running processes and restart a suspended process
jobs (view) fg jobnumber (restart job)
45
kill a process in the foreground
cntrl c
46
kill a process in the background
kill %jobnumber
47
report space left on system
df