Linux commands Flashcards

1
Q

how to find a particular file in a directory ?
e.g find test.txt in /home/shrirang/ddd/xyd/

A

find ./data -name test.txt

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

find all the files of an extension in a directory

A

find . -type f -name “*.txt”

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

list all extension files in a directory

A

find . -type f | perl -ne ‘print $1 if m/.([^.\/]+)$/’ | sort -u

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

basic grep command in single file

A

grep term filename

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

grep in files with specific extensions

A

grep -inr –include *.h –include *.cpp {term} {path}

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

list size of directories sorted

A

sudo du -hs * | sort -hr

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

find a directory in a path and all its sub-directories

A

find . -type d -name “enom”
find . -type d -name “enom*”

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

find a file in a path and all its sub-directories

A

find . -type file -name *.txt

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

list the sizes of directories

A

sudo du -hs * | sort -hr

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

How to print specified column in text

A

awk ‘{print $1}’

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

Add user and make the user sudo and change password

A

useradd

sudo usermod -aG sudo

sudo passwd

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

reset the /etc/apt/sources.list

A

sudo apt-get install –reinstall apt

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