grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name ”*filename*” – Starting with the root directory, look for the file containing the string filename
locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containingTextStringToFind
Create a new tar archive.
$ tar cvf archive_name.tar dirname/
Extract from an existing tar archive.
$ tar xvf archive_name.tar
View an existing tar archive.
$ tar tvf archive_name.tar
More tar examples: The Ultimate Tar Command Tutorial with 10 Practical Examples
Full DetailI’m more secure on Linux than I am on Windows. Yup, that’s right. I have no doubt whatsoever that I am.
I started down this path by comparing how secure I am on a Mac vs. on Windows, then I compared Mac vs. Linux. To complete that trifecta, I guess it’s only fair to compare the end-user data security aspects of Windows against Linux.
Before I get into my rationale, though, just a little more background is in order. I started using a UNIX desktop way back in college and was always comfortable there. At my first couple of jobs after college, I mostly used UNIX workstations from Dec and Sun as my primary desktops.
Later, I started using Windows-based systems at the office, but never felt quite at home. I was constantly frustrated by the frequent reboots, lack of serious security capabilities (from my perspective), and such. Then, following a brief foray in OS/2, I quickly gravitated to running Linux at home so I could once again have a real multi-tasking working environment.
Nowadays, my primary desktop is on a Macbook Pro – the best computer I’ve ever owned, without any doubt.
Full Detailps aux | grep -v `whoami`Or, to be a little more clever, why not just list the top ten time-wasters:
ps aux --sort=-%cpu | grep -m 11 -v `whoami`It is probably best to run this as root, as this will filter out most of the vital background processes. Now that you have the information, you could just kill their processes, but much more dastardly is to run xeyes on their desktop. Repeatedly!
perl -i -pe 's/Windows/Linux/;' test*To replace the text Windows with Linux in all text files in current directory and down you can run this:
find . -name '*.txt' -print | xargs perl -pi -e's/Windows/Linux/ig' *.txtOr if you prefer this will also work, but only on regular files:
find -type f -name '*.txt' -print0 | xargs --null perl -pi -e 's/Windows/Linux/'Saves a lot of time and has a high guru rating!