unix questions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/66

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

67 Terms

1
New cards

how to see current directory?

pwd. output looks like: /home/accts/ehs72/tutorial

2
New cards

how to change directory?

cd dirname. no output

3
New cards

how to make directory?

mkdir newdirname

4
New cards

how to rename file or directory?

mv oldname newname

5
New cards

how to move files into different directories?

mv filename dirname

6
New cards

how to print current date or time?

date. ex: Mon Mar 31 01:54:18 PM EDT 2025

7
New cards

how to create new file?

touch newfilename

8
New cards

how to update modification date and time of a file?

touch oldfilename. results from this can be seen with ls -l

9
New cards

how to copy a file?

cp filename copyfilename

10
New cards

how to copy a directory?

cp -r dirname copydir

11
New cards

how to remove file?

rm file

12
New cards

how to remove directory?

rmdir dirnam

13
New cards

how to print out file?

cat file

14
New cards

how to print first lines of file

head

15
New cards

how to print last lines of file

tail

16
New cards

removes any directory even if not empty

rmdir -r

17
New cards

asks for permission before removing

rm -i / rmdir -i

18
New cards

prints out first five lines of filename

head -n 5 filename

19
New cards

how to just print something

echo ––whatever––

20
New cards

how to change contense of file?

echo ~your words~ > oldfilename

21
New cards

how to make a new file with words you want in it

echo ~your words~ > newfilename

22
New cards

how to add lines to a file contianing the words you want?

echo ~your words~ » oldfilename

23
New cards

returns the number of lines words and characters in filename

wc filename. ex:  1  2 10 newcrazyfile

24
New cards

what is like wc but without the filename?

wc < filename ex:  1  2 10

25
New cards

what stands for any character

?

26
New cards

what stands for any length string?

*

27
New cards

how to display the differences between two files?

diff file1 file2 ex: 1,2c1

< apple orange banana

< kiwi mango

---

> hello world

(< means its in file1, > means it’s in file2)

28
New cards

how to return a line from a file containing a certain string?

grep string filename

29
New cards

how to use grep to find all html files?

ls | grep html

30
New cards

how to use grep to find all instances of ‘hello world‘ in file1 and file2

cat file1 file2 | grep “hello world”

31
New cards

how to determine type of file?

file filename ex: comp1: directory

32
New cards

how to print out username?

whoami ex: esimmons ex: ehs72

33
New cards

what is this the output of: uid=25324708(ehs72) gid=25324708(ehs72) groups=25324708(ehs72),20166(202501_cpsc.201.01-student)

id

34
New cards

what is this the output of:  15:21:06 up 14 days,  5:55,  2 users,  load average: 0.21, 0.22, 0.20

uptime

35
New cards

what is this the output of:

qam6     pts/12       2025-03-31 15:09 (172.27.75.217)

ehs72    pts/16       2025-03-31 15:19 (172.27.203.240)

who

36
New cards

what is this the output of:  15:24:16 up 14 days,  5:58,  2 users,  load average:

0.35, 0.28, 0.22

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

qam6     pts/12   172.27.75.217    15:09   11:47   0.02s  0.01s python3 /c/cs20

ehs72    pts/16   172.27.203.240   15:19    0.00s  0.01s  0.00s w

w

37
New cards

what is this the output of: esimmons  

ttys000                         Mon Mar 31 15:33   still logged in

esimmons   ttys000                         Mon Mar 31 15:17 - 15:17  (00:00)

esimmons   ttys000                         Mon Mar 31 15:16 - 15:16  (00:00)

esimmons   ttys000                         Mon Mar 31 14:30 - 14:30  (00:00)

esimmons   ttys000                         Mon Mar 31 13:48 - 13:48  (00:00)

esimmons   ttys000                         Mon Mar 31 13:43 - 13:43  (00:00)

esimmons   ttys000                         Mon Mar 31 13:38 - 13:38  (00:00)

esimmons   ttys000                         Mon Mar 31 13:38 - 13:38  (00:00)

esimmons   ttys000                         Sun Mar 30 13:16 - 13:16  (00:00)

esimmons   ttys000                         Tue Mar 25 16:52 - 16:52  (00:00)

last

38
New cards

what is this the output of: Darwin

uname

39
New cards

what is this the output of:

4 ./.ssh

204 ./.config/pulse

du (disk storage)

40
New cards

what is this the output of:             

  total        used        free      shared  buff/cache   available

Mem:       131456752     4799364    59037008       56476    67620380   125348616

Swap:        2097148           0     2097148

free

41
New cards

what is this the output of:

Login: sbs5           Name: Slade Stephen

Directory: /home/accts/sbs5         Shell: /bin/bash

Last login Mon Mar 31 10:24 (EDT) on pts/0 from 10.66.205.218

No mail.

No Plan.

finger sbs5

42
New cards

how are read write execute permissions stored?

3 bits for you, group, and world. in order read write execute. represented in binary.

43
New cards

how to change permissions on a file or directory?

chmod 777 (or other number) file-or-dir-name

44
New cards

how to change owner or group?

chown/chgrp new-owner file

45
New cards

how to define a variable? How do define a variable equal to a unix command? An expression?

VAR=’var definition’; VAR=$(pwd) BACKTICKS

46
New cards

how to print the value of a variable?

echo $VAR

47
New cards

how do you display the value of variables?

set

48
New cards

how to remove a variable definition?

unset VAR

49
New cards

how to find the type of a command?

type command

50
New cards

what is this the output of: cat is /usr/bin/cat; cd is a shell builtin

type cat; type cd

51
New cards

what is this the output of: /usr/bin/cat

which cat

52
New cards

how to zip and unzip?

gzip, gunzip

53
New cards

how to print out last 10 commands?

history 10

54
New cards

what does !-2 do? what does !cat do?

exicute second to last command, exicute last cat command

55
New cards

how to execute code in a file?

source filename

56
New cards

what is this the output of?

alias less='less -R'

alias lisp='/usr/bin/sbcl'

alias ll='ls -alF'

alias

57
New cards

how to define a new command

alias comand_to_type=command

58
New cards

what is this the output of:    

PID TTY          TIME CMD

2965211 pts/6    00:00:00 bash

2967742 pts/6    00:00:00 python3

2967825 pts/6    00:00:00 sh

2967826 pts/6    00:00:00 ps

ps

59
New cards

what is this the result of?

[1]+  Running                 sleep 100 &

>sleep 100 &

>jobs

60
New cards

what is this the output of?

[1]-  Running       sleep 100 &

[2]+  Terminated    sleep 50

>sleep 100 &

>sleep 50 &

>kill %2

>jobs

61
New cards

how to resume paused jobs in the background

bg %#

62
New cards

how to move a job from the background to the foreground

fg #%

63
New cards

what does a A “+” refer to? a “-” ?

current job, past job.

64
New cards

Suspend process in the foreground and move it to the background.

^Z

65
New cards

what is this the output of:

[1]+  Stopped                 python3 query_optimal_fast.py

^Z

66
New cards

what is this the output of:

[1] 11563

sleep 100 &

67
New cards

what is the input for:

ls is aliased to `ls --color=auto'

>alias ls=