Learning Unix Flashcards

1
Q

how to check hostname?

A

hostname

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

How to check your current location

A

pwd

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

How to check system date and time

A

date

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

how to check system date/ Current date

A

date +%D

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

How to check system time

A

date +%T

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

How to check only hour

A

date +%H

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

How to check with Hour with min

A

date +%H:%M

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

How to check file and directory/ Folder we have in present location

A

ls

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

How to display the detail explanation about files and folder

A

ls -ltr

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

How to know the file size in kb/mb

A

ls -lh

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

How to clear the terminal

A

clear

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

How to create any folder

A

mkdir folder_name/directory

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

how to enter new folder

A

cd folder_name

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

how to create file

A

touch file_name

So that means you can actually add any file you’d like

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

How to open any file name

A

cat file_name
view file_name
less file_name ( Shift+g is to go last line of the terminal ….. press p to read the first line

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

How to edit any existing file

A

vi file_name

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

How to remove/delete any file

A

rm file_name

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

how to delete folder/directory

A

rmdir folder_name OR rm -rf folder_name

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

How to change/rename existing file_name

A

mv old_file_name new_file_name

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

How to move one file from one location to another

A

mv file_name path(where we want to move that file)

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

How to copy any file

A

cp file_name new_file_name

22
Q

how to display first four lines

A

head -4 file_name

23
Q

how to display last four lines

A

tail -4 file_name

24
Q

How to read or display top 5 lines from any file

A

head -5 file_name

25
How to read display or display bottom/last 10 lines from any file
tail -10 file_name
26
How to sort the content from a file
sort file_name
27
How to sort the content and then put the sort content into the new file
sort file_name > new_file_name
28
How to reverse sort the content
sort -r file_name
29
How to display a unique content/record from a file
sort file_name | uniq
30
If a file has 16 lines how to split this file in 3 different file ?
split -1 4 file_name
31
How to search a word and to display any word from a file
grep "word" file_name
32
How to search multiple word from a file
egrep "first_word"|second_word" file_name
33
How to create 10 files by using range of pattern
touch {1..10}
34
How to count number of lines in any file
wc -1 file_name
35
How to count word in any file
wc -w file_name
36
How to count total character in any file
wc -c file_name
37
d-------> r--------> w--------> x---------> | This is basically understanding what each letter stands for and what it
-> directory -> read -> write -> execute
38
- + ? | What are these used for ?
- that means to take permission + is used to give permission
39
When it's time to read, write, or execute what are the numbers you would use to command in UNIX ? And what number would you use when it's time to use all permission( read, write, execute) ?
r ---->4 w -----> 2 e -----> 1 (r,w,e) ----> 7
40
When dealing with rwx, what are the first three reasons why we use them ?
1. rwx = user/developer/creator 2. rwx = group member 3. rwx = for client and other team member
41
What unix command is used to give or take permission to any file/directory( folder)
chmod
42
We want to give read, write, and execute permission to developer and no other permission to client or team member ?
chmod +700 file_name ## Footnote The reason why its "700" is because there is NO permission to client thats why we added 0 . We gave permission once that was the issue
43
Give read permission to developer and read,write, permission to team member and read permission to other team (a.sh)
chmod +464 file_name
44
Take execute permission to group member and other client
chmod -011 file_name
45
Take read and write permission to developer and execute permission to group member and other clients
chmod -611 file_name
46
Write a unix command to give read and write permission to user, read and execute permission to team member and read permission to other team member/client
chmod +654 file_name
47
What are variables in unix ?
A variable is a character string to which we assign a value
48
How to create a script and how to run it ?
#!/bin/bash and # First line of script echo "My name is parth" | the echo is how you would right the script
49
Write a script where I need to take 2 variables name = Parth and age = 33 and print below string " My name is Parth Shorey and my age is 33"
#!/bin/bash name = ' Parth Shorey' age = 33 echo "My name is Parth shorey and my age is 33"
50
What are the three commands to run scripts ?
1. ./ script_name 2. bash script_name 3. path/ script_name
51