Labels

Showing posts with label A. Show all posts
Showing posts with label A. Show all posts

Aliases are custom commands

Aliases are custom commands which can be used to make the work with the shell easier and faster. For example, if your current working directory is /usr/bin and you want to quickly go to /var/cache/apt/archives you can do a 'cd /var/cache/apt/archives'. If you want to save time, you may want to type only a command such as 'cache' or 'debs. Or you may want to update your Debian system in one command, so instead of typing 'su -c "apt-get update && apt-get upgrade"' you only type 'upgrade' or something of your choice. This is where aliases come to help.

In this How-To I will explain two ways of creating aliases.

Method 1
The first method is to add aliases directly into your ~/.bashrc file. The format should be:
alias name='command'
For example you can add something like:
alias ll='ls -l'
alias deb='cd /var/cache/apt/archives'
alias dld='cd ~/downloads'
alias upgrade='su -c "apt-get update && apt-get upgrade"'
Open a console and try your aliases. For example if you type 'deb', the current working directory will be changed to /var/cache/apt/archives.

Method 2
The second method lets you make a separate aliases file, so you won't have to put them in ~/.bashrc, but to a file of your choice. First, edit your ~/.bashrc file and add or uncomment the following lines:
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Save it and close the file. After that, all you have to do is create a ~/.bash_aliases file and add your aliases there, with the same format specified at the first method.
READ MORE - Aliases are custom commands

How-To: Manipulate Audio Files Using CLI Tools in Debian

Note: This how-to may also work in Ubuntu and other Debian-based distributions.

This is a tutorial about using CLI (Command Line Interface) tools in Ubuntu and Debian to manipulate, encode and decode various audio formats, like FLAC or OGG Vorbis. It describes the packages needed to install, and some basic commands for converting audio files and working with CUE and FLAC files.The commands in this tutorial were tested in Kubuntu 7.10 Gutsy Gibbon and Debian Lenny, with all the updates to date.

Command line tools such as oggenc or flac can be used for example to convert FLAC (Free Lossless Audio Codec) files or WAV (WaveForm Audio Format) in OGG Vorbis files. Vorbis is a free audio codec offering lossy compression, and is known to have a smaller size and better quality (at least for lower bitrates) than the widely used MP3.

All the tools used in this tutorial are available through four packages, and to install them issue the following command as root (Ubuntu users must precede it with sudo, since the root account is disabled by default in Ubuntu):

apt-get install flac vorbis-tools cuetools shntool

These packages contain several programs and utilities for manipulating audio files. To convert a FLAC file into WAV do a:

flac -d file.flac

If there are several FLAC files in the same directory, use the command:

flac -d *.flac

And all the files with the .flac extension will be converted. Of course, one can include many more options, like the name of the output file. Do a man flac or a flac --help command to see detailed help and a list of options. To convert either WAV or FLAC files into OGG, execute one of the following commands:
oggenc -b 192 *.wav
oggenc -b 192 *.flac
The -b option refers to the bitrate of the resulting OGG file, in this case the average bitrate being 192 kbps. Or you can choose to use the quality option:

oggenc -q 6 *.flac

The quality is represented on a scale from 1 to 10, 10 being the highest. More details on the official website. Some albums may come as a single FLAC file and a CUE file which stores the information needed to split the former. In this case the programs cuebreakpoints and shnsplit come in handy:

cuebreakpoints album_name.cue | shnsplit album_name.flac

And the same goes with the WAV:

cuebreakpoints album_name.cue | shnsplit album_name.wav

It will result in several .flac or .wav files, split according to the lengths specified in the CUE file. You can also edit the CUE file with a text editor and change the split lengths, for concatenating two melodies or more in a single one.

Once you obtained the desired OGG Vorbis files, you may want to edit or remove their tags. To clear all the tags in an OGG Vorbis file, use the vorbiscomment tool. For example:
touch file
vorbiscomment -w song.ogg -c file
The first command will create an empty file (if it doesn't already exist). The second one will edit the tags in song.ogg with the info found in file, which is none. Here is a script to remove all the tags from all Vorbis files with OGG extensions in a directory:
#!/bin/bash

echo "OGG Tag Remover"
echo "Creating empty file..."
touch file

echo "Removing all tags in OGG files..."
for i in *.ogg; do
echo "Executing command 'vorbiscomment -w \"$i\" -c file'..."
nice -n 15 vorbiscomment -w "$i" -c file
done

echo "Removing empty file..."
rm file

echo "Done! All tags removed."
Copy this into a file of your choice, say vorbis_rm.bash, make it executable and then run it:
chmod 755 vorbis_rm.bash
./vorbis_rm.bash
All the tags in OGG files will be removed. This is useful when you have large albums and you want to clear some wrong edited tags in one command and start clear.

Some audio players like Amarok offer an easy tag editing system. However, to make your work even faster, you can use various Bash scripts which edit as much as is needed to just leave only fields like TITLE unfilled. Next is an example of a script which automatically fills the TRACKNUMBER field for each OGG file in a directory:
#!/bin/bash

echo "OGG TRACKNUMBER Edit"

n=1
for i in *.ogg; do
echo "Executing command 'vorbiscomment -a \"$i\" -t \"TRACKNUMBER=$n\"'"...
nice -n 15 vorbiscomment -a "$i" -t "TRACKNUMBER=$n"
n=$((n + 1))
done

echo "Done. TRACKNUMBER tags completed."
After running this script in a directory with OGG files, all of them will have the TRACKNUMBER field completed.
READ MORE - How-To: Manipulate Audio Files Using CLI Tools in Debian

Special Attributes on files

# chattr +a file1
allows write opening of a file only append mode [man]

# chattr +c file1
allows that a file is compressed / decompressed automatically by the kernel [man]

# chattr +d file1
makes sure that the program ignores Dump the files during backup [man]

# chattr +i file1
makes it an immutable file, which can not be removed, altered, renamed or linked [man]

# chattr +s file1
allows a file to be deleted safely [man]

# chattr +S file1
makes sure that if a file is modified changes are written in synchronous mode as with sync [man]

# chattr +u file1
allows you to recover the contents of a file even if it is canceled [man]

# lsattr
show specials attributes [man]
READ MORE - Special Attributes on files

Archives and compressed files

# bunzip2 file1.bz2
decompress a file called 'file1.bz2' [man]

# bzip2 file1
compress a file called 'file1' [man]

# gunzip file1.gz
decompress a file called 'file1.gz' [man]

# gzip file1
compress a file called 'file1' [man]

# gzip -9 file1
compress with maximum compression [man]

# rar a file1.rar test_file
create an archive rar called 'file1.rar' [man]

# rar a file1.rar file1 file2 dir1
compress 'file1', 'file2' and 'dir1' simultaneously [man]

# rar x file1.rar
decompress rar archive [man]

# tar -cvf archive.tar file1
create a uncompressed tarball [man]

# tar -cvf archive.tar file1 file2 dir1
create an archive containing 'file1', 'file2' and 'dir1' [man]

# tar -tf archive.tar
show contents of an archive [man]

# tar -xvf archive.tar
extract a tarball [man]

# tar -xvf archive.tar -C /tmp
extract a tarball into / tmp [man]

# tar -cvfj archive.tar.bz2 dir1
create a tarball compressed into bzip2 [man]

# tar -xvfj archive.tar.bz2
decompress a compressed tar archive in bzip2 [man]

# tar -cvfz archive.tar.gz dir1
create a tarball compressed into gzip [man]

# tar -xvfz archive.tar.gz
decompress a compressed tar archive in gzip [man]

# unrar x file1.rar
decompress rar archive [man]

# unzip file1.zip
decompress a zip archive [man]

# zip file1.zip file1
create an archive compressed in zip [man]

# zip -r file1.zip file1 file2 dir1
compress in zip several files and directories simultaneously [man]
READ MORE - Archives and compressed files

APT packages tool

# apt-cache search [package]
returns list of packages which corresponds string "searched-packages" [man]
# apt-cdrom install [package]
install / upgrade a deb package from cdrom [man]

# apt-get install [package]
install / upgrade a deb package [man]

# apt-get update
update the package list [man]

# apt-get upgrade
upgrade all of the installed packages [man]

# apt-get remove [package]
remove a deb package from system [man]

# apt-get check
verify correct resolution of dependencies [man]

# apt-get clean
clean up cache from packages downloaded [man]
READ MORE - APT packages tool