Only show filenames in grep command
Answer:
Sometimes you want the grep command only return the filenames that matched a pattern, you can try the following:
# grep -r -l "foo" .
The key is the -l option.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Only show filenames in grep command
Answer:
Sometimes you want the grep command only return the filenames that matched a pattern, you can try the following:
# grep -r -l "foo" .
The key is the -l option.
Compress and decompress file using 7zip
Answer:
7zip is a well known compression program if you need a very small file size, i.e. high compression ratio.
To install under Ubuntu/Debian:
# sudo apt-get install p7zip
To compress a file
# p7zip test.txt
To decompress a file
# p7zip -d test.txt.7z
Count the total number of logged in user
Answer:
To count the total number of logged in user(s), use the following commands:
# who | wc -l
3
It shows currently there are 3 users logged in.
Check remote hostname using nslookup
Answer:
You can find the hostname of remote machine using the nslookup command.
# nslookup 198.182.196.48 | grep name
48.196.182.198.in-addr.arpa name = linux.org.
List all installed package in Ubuntu
Answer:
To list all the installed packages in Ubuntu, so you try the "dpkg -l" command:
E.g.
# dpkg -l