Unix Flashcards

1
Q

Where I am - Print working directory

A

pwd

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

List current directory content

A

ll, ls -al

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

read content of a file

A

cat fileName

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

clear the screen

A

clear

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

How to find unix version

A

cat /etc/issue

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

How to find cpu details

A

cat /proc/cpuinfo

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

How to find RAM on m/c

A

free -mto

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

Change directory

A

cd dirName

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

Go to root directory

A

cd /

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

Go to home directory

A

cd ~

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

Go to parent directory

A

cd ..

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

How to see command history

A

history

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

How to run a command from history

A

! CommandNumberFromHistoryList

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

Remove particular command from shell history

A

history – d

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

How to identify Directory/File in ls -al output

A

dxyzxyzxyz _xyzxyzxyz

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

How to identify link in ls -al output

A

lxyzxyzxyz

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

How to identify hidden file or directory in ls -al output

A

fileName/DirName will be prefixed with period

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

Tab completion

A

Tab - only one, Tab+Tab - if multiple files starts with same char.

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

Piping

A

ls | less

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

Chuck output into pages

A

less

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

Go to next page in Less output

A

Spacebar

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

Quit from Less output prompt

A

q

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

Is UNIX case sensitive

A

yes

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

How to get help on cat command

A

man cat

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

Copy file myFile to myNewFile

A

cp myFile myNewFile

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

Copy directory myDir to myNewDir

A

cp -r myDir myNewDir

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

Make folder myFolder

A

mkdir myFolder

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

Delete a file myFile

A

rm myFile

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

Rename a file myFile to myNewFile

A

mv myFile myNewFile

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

Wildcards

A
  • one or more
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Delete a dir myDir

A

rm -r myDir

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

duuugggooo USER GROUP

A

d=dir, uuu=user rwx permissions

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

What does x permission mean for directory

A

user can explore the folder

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

permission groups

A

u=user, g=group, o=other, a=all, r=read, w=write, x=execute,+=add permission, -=remove permissions, ==assign

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

Command to change permission on file/dir

A

chmod - Change Mod

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

who is the super user in unix

A

root

37
Q

super user do

A

sudo followed by command. you will be prompted for password

38
Q

change owner - user

A

chown newOwnerName fileName,

sudo chown newOwnerName fileName

39
Q

change owner -user+group

A

chown newOwnerName:newGroupName fileName

40
Q

How to zip a file

A

zip zippedFileName.zip fileName.txt

41
Q

How to unzip a file

A

unzip zippedFileName.zip

42
Q

Hot to GNU zip(older system)

A

gzip fileName.txt

This will replace the original file and append .gz

43
Q

Unzip GNU zip

A

gunzip fileName.txt.gz

This will replace the original file.

44
Q

Which offers better compression zip or gzip

A

gzip

45
Q

What is tar ball

A

No compression, just bundling multiple files into single file.

46
Q

How to create a tar ball

A

tar -cvf tarFileName.tar form*

47
Q

How to extract a tar ball

A

tar -xvf tarFileName.tar

48
Q

How to create compressed tar ball

A

tar -cvfz tarFileName.tgz form*

49
Q

How to extract a compressed tar ball

A

tar -xvfz tarFileName.tgz

50
Q

How to create symbolic link(shortcuts)

A

ls -s fullFilePath OptionalLinkName

51
Q

SSH(Secure Shell)

A

ssh -p8080 userName@serverName

will be prompted for password.

52
Q

How to terminate SSH session

A

exit

53
Q

Secure Copy

A

scp FROM TO

scp -r -P8080 userName@serverName:fullPath localPath

54
Q

create a blank test.txt file

A

touch test.txt

55
Q

How to find test.txt against database

A

locate test.txt

56
Q

How to update database

A

updatedb [updatedb generally runs on CRON Job]

57
Q

How to find test.txt without using database

A

find pathToSearch -name fileName

find / -name test.txt

58
Q

GREP

A

Global Regular Expression Print

59
Q

Search for “theme” in index.php

A

grep ‘theme’ index.php

60
Q

Search for “theme” in all files in current directory

A

grep ‘theme’ *

61
Q

Search for “theme” in all files in current directory and child directories

A

grep -r ‘theme’ *

62
Q

How to display line# in grep output

A

-n flag

63
Q

How to just display file names in grep output

A

-l flag

64
Q

How to find all files which does not meet grep criteria

A

-v flag

65
Q

How to ignore case in grep search

A

-i flag

66
Q

How to find location of a command

A

which commandName e.g which vi

67
Q

vi editor - How to move cursor

A

arrow keys or HJKL

68
Q

vi editor - How to move cursor multiple times

A

7J

69
Q

vi editor - command mode/insert mode

A

esc=Enter command mode, insert=Enter insert mode.

70
Q

Goto line #

A

:10 - will take you to line 10

:1 - will take you to first line.

71
Q

Goto bottom of file

A

G(capital)

72
Q

start/end of line

A

0=start of line, $=end of line

73
Q

Delete entire line

A

dd

74
Q

Undo

A

u

75
Q

Discard all changes till last save(:w)

A

:e!

76
Q

Save document in current state

A

:w

77
Q

Save and quit

A

:wq

78
Q

Force quit

A

:q!

79
Q

copy

A

yy=copy entire line, 3yy=copy 3 lines, yw=copy word

80
Q

paste

A

p

81
Q

copy selected text

A

y=yanked

82
Q

How to find differences

A

diff fileName1 fileName2

83
Q

Where alias are stored

A

Unix=.bashrc, MAC=.bash_profile

84
Q

How to create alias

A

alias ll=”ls -al” and start new terminal session.

85
Q

How to read from top of a file

A

head fileName

86
Q

How to read from bottom of a file

A

tail fileName

87
Q

How to tail and follow from a file

A

tail -100f fileName

88
Q

How to identify which shell is in use

A

echo $SHELL