14 Practical examples of the grep command

grep is a command-line utility that allows searching of words and/or patterns in a file or group of files. Its name comes from the ed command g/re/p (globally search a regular expression and print). Grep does a global search by keyword or regular expression and print all matching lines on the standard output.

Exclude the process grep on ps ax output

Regularly I use ps ax | grep pattern to get information about a particular process, but in the oupout the grep process is shown, how to avoid this?

Simply encloses within square brackets the first letter or number of the pattern, for example:

Kill GNU/Linux process from the command line

Desktop like GNOME, KDE, XFCE, LXDE have a task manager that allows you to terminate a process using the graphical interface, but not always we have managers like these or we simply work without graphical interface (server) and we need to kill a particular process because it does not respond to any action, and that's when should lend hands to the console

Shell script to rename to lowercase files and directories


In the GNU/Linux world, it is common to use lowercase characters to identify files and directories, to illustrate the above we show the DIRs that are found under the /etc/apache2 DIR on Debian GNU/Linux

├── conf-available
├── conf-enabled
├── mods-available
├── mods-enabled
├── sites-available
└── sites-enabled

so if you have one or several DIRs in uppercase or lowercase and uppercase at the same time and for uniformity want to all be lowercase then you can rely on the following script.

[githubget repo=1]sysadmin/shscript/[/githubget]

To use the script download here

Set execute permissions
chmod a+x
Run the script
./ nombre-del-fichero

Further readings

  • man find
  • man tr

Get Information of my CPU on GNU/Linux

We can get CPU information in GNU/Linux by typing the following command:

$ cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 22
model name	: Intel(R) Celeron(R) CPU          430  @ 1.80GHz
stepping	: 1
cpu MHz		: 1800.045

Find duplicated files in GNU/Linux

One of the easiest and safest ways to find duplicate files on GNU / Linux files is using the tool fdupes, fdupes find duplicate files comparing the file sizes, making a check MD5 followed by a byte to byte comparison.

Mount ISO, BIN and NRG images

GNU/Linuxfuseiso is an utility that allows you to mount ISO, BIN and NRG images in the userspace file system then you can browse them with any file manager such as any directory can be inspected.

Install fuseiso

Debian/Ubuntu and derivatives

$ sudo apt-get install fuseiso

Enable rpmforge

# yum install fuse-iso

Use fuseiso

$ fuseiso -p my.iso access-point

access-point = DIR where you will mount the image

Unpack .iso with 7-Zip

See 7-Zip – An excellent archive compressor / decompressor

Further reading

– man fuseiso

7-Zip – An excellent archive compressor / decompressor

7-zip is a file compressor with a high ratio of compression. The main features are:

  • High ratio of compression (LZMA algorithm)
  • Compress / decompress: 7z, ZIP, GZIP, BZIP2 and TAR
  • Robust encryption: AES-256 for 7z and ZIP formats
  • Allows to create self-extracting archives (SFX)
  • Command line version
  • Integration with File Roller, XArchiver and XArchive
  • Multi-platform
  • Multi-language