Linux commands Flashcards
how to find a particular file in a directory ?
e.g find test.txt in /home/shrirang/ddd/xyd/
find ./data -name test.txt
find all the files of an extension in a directory
find . -type f -name “*.txt”
list all extension files in a directory
find . -type f | perl -ne ‘print $1 if m/.([^.\/]+)$/’ | sort -u
basic grep command in single file
grep term filename
grep in files with specific extensions
grep -inr –include *.h –include *.cpp {term} {path}
list size of directories sorted
sudo du -hs * | sort -hr
find a directory in a path and all its sub-directories
find . -type d -name “enom”
find . -type d -name “enom*”
find a file in a path and all its sub-directories
find . -type file -name *.txt
list the sizes of directories
sudo du -hs * | sort -hr
How to print specified column in text
awk ‘{print $1}’
Add user and make the user sudo and change password
useradd
sudo usermod -aG sudo
sudo passwd
reset the /etc/apt/sources.list
sudo apt-get install –reinstall apt