MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat
10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Oct Nov Dec

Sat, Mar 09, 2019 4:25 pm

Installing and using cdparanoia to rip CDs on a CentOS Linux system

If you need to rip a CD from a command-line interface (CLI) on a CentOS Linux system, cdparanoia will allow you to do so. The cdparanoia CD ripper program will allow you to produce Waveform Audio File Format, i.e., .WAV, files from the tracks on a CD. You can use the yum package management software to install the software with by issuing the command yum install cdparanoia from the root account.

[ More Info ]

[/os/unix/linux/centos/music] permanent link

Fri, Mar 08, 2019 9:12 pm

Accessing the RPM Fusion repository from a CentOS system

Sometimes you may find that a software package that you would like to use on a CentOS Linux system is unavailable from the default software repositories, aka "repos." In such cases adding alternative repos, such as Extra Packages for Enterprise Linux (EPEL) or RPM Fusion may allow you to locate the desired package. E.g., the VLC media player is available in the RPM Fusion repository, but not the default ones nor in EPEL. RPM Fusion has two separate software repositories, one that contains free and open-source software (FOSS) and another named "nonfree". Packages in the "nonfree" repository still won't cost you anything, but there may be restrictions on the use of the software, e.g., you may be forbidden from using the software for commercial use. The RPM Fusion site defines the nonfree repo as being 'for redistributable software that is not Open Source Software (as defined by the Fedora Licensing Guidelines); this includes software with publicly available source-code that has "no commercial use"-like restrictions.'

[ More Info ]

[/os/unix/linux/centos] permanent link

Tue, Jan 01, 2019 10:42 pm

Creating new directories for a new year

I have a number of log directories where I store log files where the directory name is the current year. On the last day of the old year, I want to create new directories named for the upcoming year. I use the following Bash script to create those directories. Since I have several email log directories, I use a for loop to create a directory named after the upcoming year in each one.

# Create a new directory corresponding to the upcoming year on December 31 of
# every year

newyear=$(date --date=tomorrow +%Y)
echo $newyear

# Apache logs

# Check on whether the directory for the current year exists and, if it doesn't,
# create it.
if [ ! -d /home/jdoe/www/logs/apache/"$newyear" ]; then
   mkdir /home/jdoe/www/logs/apache/"$newyear"
   chown apache /home/jdoe/www/logs/apache/"$newyear"
   chgrp apache /home/jdoe/www/logs/apache/"$newyear"

# Email logs 

# Create an array holding the names of the 4 directories within which
# subdirectories will be created using the name of the new year. E.g.,
# /home/jdoe/www/logs/mail/sendmail_stats/2019

logdirs=( "dnsbl_count" "sendmail_stats" "smlogstats" "smreject"  )

for i in "${logdirs[@]}"
do :
   # Check on whether the directory for the current year exists and, if it 
   # doesn't, create it.
   if [ ! -d /home/jdoe/www/logs/mail/$i/"$newyear" ]; then
      mkdir /home/jdoe/www/logs/mail/$i/"$newyear"
      chown jdoe /home/jdoe/www/logs/mail/$i/"$newyear"
      chgrp jdoe /home/jdoe/www/logs/mail/$i/"$newyear"

I then have a crontab entry containing the following line that will result in the Bash script above, named end-of-year-dirs, being run at 7;00 AM on December 31 of each year.

0 7 31 DEC * /root/bin/end-of-year-dirs

Related articles:

  1. Loop through an array in Bash
  3. crontab -e
  4. smlogstats

[/os/unix/bash] permanent link

Fri, Jun 22, 2018 10:51 pm

Regular expression to find words/strings not ending with a character

If you wish to find strings at the end of a line that don't end with a particular character, you can use a bracket expresion with a caret character after the left square bracket in a regular expression.

Metacharacter Description
[^ ] Matches a single character that is not contained within the brackets. For example, [^abc] matches any character other than "a", "b", or "c". [^a-z] matches any single character that is not a lowercase letter from "a" to "z". Likewise, literal characters and ranges can be mixed.

[ More Info ]

[/os/unix/commands] permanent link

Sun, Feb 04, 2018 11:03 pm

Run a cronjob at the end of every year

At the end of every year, I need to create some new directories to hold log files with the directory name reflecting the new year on a CentOS Linux system. To create those directories on the last day of the year, December 31, I can use the cron utility found on Linux/Unix and OS X/MacOS systems to schedule a cronjob to run on the last day of the year. I can edit the crontab file that holds jobs to be run at a scheduled time or times by issuing the crontab command crontab -e, which will allow me to edit the file with the vi editor. If the vi editor is the default editor, which it likely is, but you are unfamiliar with that editor, you can change the editor for the current login session to the GNU nano text editor, which may be easier to use for someone unfamiliar with the vi text editor, by issuing the following command at the command line.

export EDITOR="/usr/bin/nano"

The value will be reset when you log off or you can reset it manually with the command below:

export EDITOR="/usr/bin/vi"

I can put the following line in the crontab file to run my script named end-of-year-dirs at 7:00 AM on December 31 of every year. When you add a new entry, be sure to hit the Enter key at the end of the line.

0 7 31 DEC * /home/jdoe/scripts/end-of-year-dirs

[ More Info ]

[/os/unix/commands] permanent link

Thu, Jan 18, 2018 11:55 pm

Viewing the login history for a user on a Linux or OS X system

If you want to see the IP addresses from which logins have occurred on a Linux or OS X system, you can use the last command. E.g.:

$ last ann
ann      tty2                          Thu Jan  5 20:23 - 20:27  (00:03)
ann      tty2                          Thu Jan  5 20:05 - 20:06  (00:00)
ann      tty2                          Thu Jan  5 20:01 - 20:02  (00:00)
ann      pts/0       Sun Oct 30 10:43 - 16:59  (06:16)
ann      pts/0      Tue Oct 11 12:02 - 12:03  (00:00)
ann      pts/0      Tue Oct 11 12:01 - 12:01  (00:00)
ann      pts/32      Sat Jun 11 20:03 - 20:38  (00:35)
ann      pts/32      Sat Jun 11 13:23 - 14:22  (00:58)
ann      pts/14      Sun Feb 14 17:05 - 18:28 (6+01:22)
ann      pts/6        Sun Nov  8 09:23 - 10:16  (00:52)
ann      pts/6        Sat Nov  7 08:54 - 16:42  (07:48)
ann      pts/7        Fri Nov  6 16:47 - 16:49  (00:02)
ann      pts/6        Fri Nov  6 15:48 - 23:33  (07:44)
ann      pts/0        :0               Thu Sep 10 15:25 - 12:38 (129+22:13)
ann      :0           :0               Thu Sep 10 15:24 - 12:38 (129+22:14)
ann      pts/5        :0               Sun Aug 23 11:08 - crash (18+04:03)
ann      pts/4        :0               Sat Aug 22 21:16 - crash (18+17:56)
ann      pts/3        :0               Sat Aug 22 09:14 - crash (19+05:58)
ann      :0           :0               Sat Aug 22 09:07 - crash (19+06:05)
ann      pts/2      Sun Jul 19 15:41 - 20:59 (1+05:18)
ann      pts/2      Mon Jun 22 21:28 - 20:17 (18+22:49)
ann      pts/2      Fri Feb  6 21:26 - 21:26  (00:00)
ann      pts/5      Wed Nov  5 21:07 - 22:15  (01:08)

wtmp begins Sun Oct  5 20:09:11 2014

[ More Info ]

[/os/unix/commands] permanent link

Fri, Jan 12, 2018 10:55 pm

Viewing only the files created today on a Linux system

I sometimes need to see only the files created or modified today in a directory. On a Linux system, you can pipe the output of the ls command into the grep command looking for just today's date in the input to the grep command as shown below:

$ ls -al --time-style=+%D ~/Documents/*.zip | grep $(date +%D)
-rw-r--r--. 1 joe joe   269338 01/12/18 /home/joe/Documents/

You can specify how the date is displayed with +format where format is a particular format in which you want the date displayed - see Formatting the output from the date command on a Linux system. If you use +%D, the date will be displayed as m/d/y, i.e., month/day/year, e.g. 01/12/18 for January 12, 2018. By then using the grep command to search for that value, you can limit the displayed files to only those created or modified today.

[ More Info ]

[/os/unix/commands] permanent link

Tue, Dec 12, 2017 11:25 pm

NetworkManager and nm-tool

If you wish to check the speed of network interfaces on a CentOS Linux system, if the nm-tool utility, is installed, then you can use it to determine the speed of the network ports.

$ nm-tool

NetworkManager Tool

State: disconnected

- Device: em1 ------------------------------------------------------------------
  Type:              Wired
  Driver:            bnx2
  State:             unmanaged
  Default:           no
  HW Address:        D4:AE:52:CD:0A:D4

    Carrier Detect:  yes
    Speed:           1000 Mb/s

  Wired Properties
    Carrier:         on

- Device: em2 ------------------------------------------------------------------
  Type:              Wired
  Driver:            bnx2
  State:             unmanaged
  Default:           no
  HW Address:        D4:AE:52:CD:0A:D5

    Carrier Detect:  yes

  Wired Properties
    Carrier:         off


If it is installed, the nm-tool program will likely be in /usr/bin . It is part of the NetworkManager package.

[ More Info ]

[/os/unix/linux/centos] permanent link

Sun, Dec 10, 2017 7:39 pm

Determining the version of CentOS on a system

If you are logged into a CentOS Linux system, there are a few ways you can determine the version of CentOS running on the system from a command-line interface (CLI), i.e., a shell prompt.

In the /etc directory, there should be a /etc/centos-release file containing information on the version of CentOS.

$ ls -l /etc/*elease
-rw-r--r--  1 root root  27 Mar 28  2017 /etc/centos-release
-rw-r--r--. 1 root root 152 Nov 25  2013 /etc/lsb-release
lrwxrwxrwx  1 root root  14 Apr 20  2017 /etc/redhat-release -> centos-release
lrwxrwxrwx  1 root root  14 Apr 20  2017 /etc/system-release -> centos-release
$ cat /etc/*elease
CentOS release 6.9 (Final)
CentOS release 6.9 (Final)
CentOS release 6.9 (Final)

To just see the version number, you can use one of the grep commands below.

$ grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release
$ grep -oE '[0-9]+\.[0-9]+' /etc/centos-release

[ More Info ]

[/os/unix/linux/centos] permanent link

Thu, Sep 07, 2017 10:38 pm

Looping over a set of files in the Bash shell on Linux or OS X

I have a Python script,, that takes a file name as a parameter. I use the script to identify if a file with a .bin extension is actually a Microsoft Visio or PowerPoint file. I run the script on an OS X system from a Terminal window where I have a Bash shell prompt. E.g.:

$ ~/Documents/bin/ oleObject1.bin
Microsoft Office PowerPoint

But I often want to have it check all of the .bin files in a directory. You can loop through all files in a directory or a set of files using a Bash for loop. E.g., to check all of the .bin files in a directory I could use the for-loop below:

$ ls *
oleObject1.bin	oleObject3.bin	oleObject5.bin
oleObject2.bin	oleObject4.bin	oleObject6.bin
$ for f in *.bin; do ~/Documents/bin/ $f; done
Microsoft Office PowerPoint
Microsoft Office PowerPoint
Microsoft Office PowerPoint
Microsoft Visio
Microsoft Visio
oleObject6.bin: CDF V2 Document, No summary info


[ More Info ]

[/os/unix/bash] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo