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
Q

How to read display or display bottom/last 10 lines from any file

A

tail -10 file_name

26
Q

How to sort the content from a file

A

sort file_name

27
Q

How to sort the content and then put the sort content into the new file

A

sort file_name > new_file_name

28
Q

How to reverse sort the content

A

sort -r file_name

29
Q

How to display a unique content/record from a file

A

sort file_name | uniq

30
Q

If a file has 16 lines how to split this file in 3 different file ?

A

split -1 4 file_name

31
Q

How to search a word and to display any word from a file

A

grep “word” file_name

32
Q

How to search multiple word from a file

A

egrep “first_word”|second_word” file_name

33
Q

How to create 10 files by using range of pattern

A

touch {1..10}

34
Q

How to count number of lines in any file

A

wc -1 file_name

35
Q

How to count word in any file

A

wc -w file_name

36
Q

How to count total character in any file

A

wc -c file_name

37
Q

d——->
r——–>
w——–>
x———>

This is basically understanding what each letter stands for and what it

A

-> directory
-> read
-> write
-> execute

38
Q
    • ?

What are these used for ?

A
  • that means to take permission

+ is used to give permission

39
Q

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) ?

A

r —->4
w —–> 2
e —–> 1

(r,w,e) —-> 7

40
Q

When dealing with rwx, what are the first three reasons why we use them ?

A
  1. rwx = user/developer/creator
  2. rwx = group member
  3. rwx = for client and other team member
41
Q

What unix command is used to give or take permission to any file/directory( folder)

A

chmod

42
Q

We want to give read, write, and execute permission to developer and no other permission to client or team member ?

A

chmod +700 file_name

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
Q

Give read permission to developer and read,write, permission to team member and read permission to other team (a.sh)

A

chmod +464 file_name

44
Q

Take execute permission to group member and other client

A

chmod -011 file_name

45
Q

Take read and write permission to developer and execute permission to group member and other clients

A

chmod -611 file_name

46
Q

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

A

chmod +654 file_name

47
Q

What are variables in unix ?

A

A variable is a character string to which we assign a value

48
Q

How to create a script and how to run it ?

A

!/bin/bash and # First line of script

echo "My name is parth"

the echo is how you would right the script

49
Q

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”

A

!/bin/bash

name = ‘ Parth Shorey’
age = 33

echo “My name is Parth shorey and my age is 33”

50
Q

What are the three commands to run scripts ?

A
  1. ./ script_name
  2. bash script_name
  3. path/ script_name
51
Q
A