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
Copy file myFile to myNewFile
cp myFile myNewFile
26
Copy directory myDir to myNewDir
cp -r myDir myNewDir
27
Make folder myFolder
mkdir myFolder
28
Delete a file myFile
rm myFile
29
Rename a file myFile to myNewFile
mv myFile myNewFile
30
Wildcards
* one or more
31
Delete a dir myDir
rm -r myDir
32
duuugggooo USER GROUP
d=dir, uuu=user rwx permissions
33
What does x permission mean for directory
user can explore the folder
34
permission groups
u=user, g=group, o=other, a=all, r=read, w=write, x=execute,+=add permission, -=remove permissions, ==assign
35
Command to change permission on file/dir
chmod - Change Mod
36
who is the super user in unix
root
37
super user do
sudo followed by command. you will be prompted for password
38
change owner - user
chown newOwnerName fileName, | sudo chown newOwnerName fileName
39
change owner -user+group
chown newOwnerName:newGroupName fileName
40
How to zip a file
zip zippedFileName.zip fileName.txt
41
How to unzip a file
unzip zippedFileName.zip
42
Hot to GNU zip(older system)
gzip fileName.txt | This will replace the original file and append .gz
43
Unzip GNU zip
gunzip fileName.txt.gz | This will replace the original file.
44
Which offers better compression zip or gzip
gzip
45
What is tar ball
No compression, just bundling multiple files into single file.
46
How to create a tar ball
tar -cvf tarFileName.tar form*
47
How to extract a tar ball
tar -xvf tarFileName.tar
48
How to create compressed tar ball
tar -cvfz tarFileName.tgz form*
49
How to extract a compressed tar ball
tar -xvfz tarFileName.tgz
50
How to create symbolic link(shortcuts)
ls -s fullFilePath OptionalLinkName
51
SSH(Secure Shell)
ssh -p8080 userName@serverName | will be prompted for password.
52
How to terminate SSH session
exit
53
Secure Copy
scp FROM TO | scp -r -P8080 userName@serverName:fullPath localPath
54
create a blank test.txt file
touch test.txt
55
How to find test.txt against database
locate test.txt
56
How to update database
updatedb [updatedb generally runs on CRON Job]
57
How to find test.txt without using database
find pathToSearch -name fileName | find / -name test.txt
58
GREP
Global Regular Expression Print
59
Search for "theme" in index.php
grep 'theme' index.php
60
Search for "theme" in all files in current directory
grep 'theme' *
61
Search for "theme" in all files in current directory and child directories
grep -r 'theme' *
62
How to display line# in grep output
-n flag
63
How to just display file names in grep output
-l flag
64
How to find all files which does not meet grep criteria
-v flag
65
How to ignore case in grep search
-i flag
66
How to find location of a command
which commandName e.g which vi
67
vi editor - How to move cursor
arrow keys or HJKL
68
vi editor - How to move cursor multiple times
7J
69
vi editor - command mode/insert mode
esc=Enter command mode, insert=Enter insert mode.
70
Goto line #
:10 - will take you to line 10 | :1 - will take you to first line.
71
Goto bottom of file
G(capital)
72
start/end of line
0=start of line, $=end of line
73
Delete entire line
dd
74
Undo
u
75
Discard all changes till last save(:w)
:e!
76
Save document in current state
:w
77
Save and quit
:wq
78
Force quit
:q!
79
copy
yy=copy entire line, 3yy=copy 3 lines, yw=copy word
80
paste
p
81
copy selected text
y=yanked
82
How to find differences
diff fileName1 fileName2
83
Where alias are stored
Unix=.bashrc, MAC=.bash_profile
84
How to create alias
alias ll="ls -al" and start new terminal session.
85
How to read from top of a file
head fileName
86
How to read from bottom of a file
tail fileName
87
How to tail and follow from a file
tail -100f fileName
88
How to identify which shell is in use
echo $SHELL