Showing posts with label cli. Show all posts
Showing posts with label cli. Show all posts

Collection of 18 Popular APT & DPKG Tips for Debian and Ubuntu

    This is a guide containing the most popular and useful ways of using the APT and DPKG commands, and it applies to both Ubuntu and Debian (and their derivatives). I mentioned where super user privileges are required, the ones without a mention can be executed as normal user. If you're using Ubuntu, precede a command with sudo in order to gain root privileges (and enter your user password); on Debian, type su, enter the root password, and then type in the commands as shown below.

    dpkg -L package_name
    This command will show what files package_name installed on your computer. Notice that this works only for already installed packages. Example:

    embryo@debian:~$ dpkg -L vorbis-tools

    /.

    /usr

    /usr/bin

    /usr/bin/ogg123


    apt-get build-dep package_name

    (needs root privileges)
    This is a very useful command, which will install all the development libraries needed by an application. So if you need to compile a newer version of a program than the one included in the repositories, use this command to fetch the dependencies. Notice that the libraries installed will be for the current version coming with the repositories, so you may need to install additional libraries if needed. However, this usually works for most of the applications. Example:

    apt-get build-dep wesnoth


    This will fetch all the development packages needed for Wesnoth. Keep in mind that your sources repositories must be enabled (they are enabled by default in Ubuntu).

    apt-get clean (and apt-get autoclean)
    (needs root privileges)
    This command will remove the archives installed on your system. Whenever you install a package, it is downloaded and the DEB package is kept inside the /var/cache/apt/archives/ directory. This command removes those packages, freeing up space.

    apt-get clean
    apt-get autoclean


    Regarding apt-get autoclean: this command will remove only the archives which are no longer available in the repositories, and will keep the ones which are currently available. Helpful if you want to get rid of old archives which have been updated, but still want to keep the upgraded ones just in case. To see how much space the archive occupy, use du -h (the -h argument stands for human readable, so it will show sizes in human readable format):

    du -h /var/cache/apt/archives/


    apt-cache show package_name
    Will show information about any package in the repository. You only have to type in the name of it, not the entire name and version. Example:

    embryo@debian:~$ apt-cache show vorbis-tools

    Package: vorbis-tools

    Priority: optional

    Section: sound

    Installed-Size: 580

    ...


    apt-cache search pattern
    Will search and list all the packages which contain pattern in their name or in their description. You can pipe this with grep for more relevant results:

    embryo@debian:~$ apt-cache search gnome terminal|grep terminal

    gmfsk - MFSK, RTTY and other digital mode terminal for HF/amateur radio

    gnome-terminal-data - Data files for the GNOME terminal emulator

    gnome-terminal - The GNOME 2 terminal emulator application


    apt-get update && apt-get upgrade
    (needs root privileges)
    This is a one-liner to update your packages list and upgrade your system. Since it requires root privileges, if your distribution is Ubuntu use sudo apt-get update && sudo apt-get upgrade. Notice that the second command (after the double ampersand) is executed only if the first one was successful, so if fetching any of the lists fails, the second command will not be executed. If you're running a testing or beta release, use instead the following:

    sudo apt-get update && sudo apt-get dist-upgrade


    This will fetch updates even if they depend on newer packages.

    dpkg --get-selections

    This command will list all the packages installed on a system using the package manager. Example:

    embryo@debian:~$ dpkg --get-selections

    acpi-support-base install

    acpid install

    adduser install

    akregator install

    ...


    dpkg -S filename
    Will list the packages which install filename. Example:

    embryo@debian:~$ dpkg -S oggenc
    vorbis-tools: /usr/share/man/man1/oggenc.1.gz
    vorbis-tools: /usr/bin/oggenc

    embryo@debian:~$


    apt-get autoremove
    (needs root privileges)
    This command will remove unnecessary packages (e.g. orphaned packages), which are no longer needed by any of the packages installed in the system. This happens often after you uninstall a certain application, and its dependencies still remain installed on the system. Use this command to get rid of them.

    apt-cache dump
    This command will list every package in the cache.

    apt-cache depends package_name
    A very useful command which lists every dependency a package has, including recommended packages.

    embryo@debian:~$ apt-cache depends vorbis-tools
    vorbis-tools

    Depends: libao2

    Depends: libc6

    Depends: libcurl3-gnutls

    ...


    apt-cache rdepends package_name
    Will show dependencies in reversed order, that is, it will list all the packages which depend on the specified package.

    apt-cache rdepends mplayer

    apt-cache policy package_name
    This will list the repository in which a package is located. In Ubuntu, there are four such repositories: main, restricted, universe and multiverse. Debian has main, contrib and non-free. There is a certain policy for each package, and depending on that, the package is included in one of the specified repositories.

    apt-cache policy amarok
    apt-cache policy sun-java6-jre


    apt-cache showsrc package_name
    Will show information about a package source.

    apt-get -f install
    (needs root privileges)
    Will try to fix broken dependencies. This usually comes in handy if you try to manually install a DEB package without installing first its dependencies. Run apt-get -f install to fix the missing dependencies and try to install the package again.

    apt-cdrom add
    (needs root privileges)
    Will add a CD ROM to your sources, so you can install packages from it. This command is mostly useful if you have some ISO images, which you don't want to burn to a CD. In order to scan the ISO images, use:

    apt-cdrom -d=/cdrom add

    This will mount the ISO image inside the /cdrom directory, and then add its contents to the sources.list. Notice that the /cdrom directory has to be empty. You can use any empty directory for this:

    apt-cdrom -d=/home/USER/mydir

    dpkg -c local_file.deb
    The -c argument tells dpkg to list the contents of a DEB package. Example:

    embryo@debian:~$ dpkg -c google-chrome-stable_current_i386.deb
    ...

    drwxr-xr-x root/root 0 2010-07-30 23:54 ./usr/share/man/man1/

    -rwxr-xr-x root/root 3098 2010-07-30 23:54 ./usr/share/man/man1/google-chrome.1

    lrwxrwxrwx root/root 0 2010-07-30 23:54 ./usr/bin/google-chrome -> /opt/google/chrome/google-chrome


    dpkg -f local_file.deb
    This shows the control file for a binary package. A control file is a file which provides information to the package manager about dependencies, maintainer, homepage, description, and more.

    embryo@debian:~$ dpkg -f google-chrome-stable_current_i386.deb
    Package: google-chrome-stable

    Version: 5.0.375.126-r53802

    ...


    These are the most popular uses of APT and DPKG. Have some more? Please, share them!
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Guide to Using Finch - Terminal-Based Chat Client

    Finch is a TUI (text user interface) IM client for Linux which uses libpurple, the same library on which the GNOME IM client Pidgin is based on. Usually, if you have Pidgin installed, you should have Finch too, unless Pidgin was compiled with the text interface option disabled. In addition to this, Finch supports every protocol that Pidgin supports, and even though it is a terminal-based application, it offers enough configuration options, and more can be done using the .gntrc configuration file, which is discussed later in this guide. If not, installing the latest Finch release, even from source, should be easy.

    To install it in Ubuntu, open a terminal and type sudo apt-get install finch or use the Ubuntu Software Centre to search for it and install it. On Debian, you can install the older version from the repositories, or use this guide to compile and install the latest version. Yahoo! for example changed its protocol, so the version which comes included in Debian Lenny is not able to connect to it.

    A little about installing as a normal user, using a different prefix. I have Pidgin (and Finch for that matter) 2.7.3 installed in Debian Lenny under the /home/embryo/usr prefix, so my binaries are located in /home/embryo/usr/bin/ and the manual pages in /home/embryo/usr/share/man/man1/finch.1/ and /home/embryo/usr/share/man/pidgin.1/ respectively. So in order to launch them I need to include the first path into my $PATH variable. To do so, edit your ~/.bashrc file using a text editor, and add this line at the end:

    export PATH=$PATH:/home/USER/usr/bin

    Replace USER with your username (and the full path if your prefix was different). Now, I don't know if there is another workaround for this, but i noticed that man finch or man pidgin do not work after installing in a different path than the standard ones. The manual pages for them actually exist, but in the directory /home/embryo/usr/share/man/man1/. So, to access them, use these commands:

    man -l /home/USER/usr/share/man/man1/finch.1
    man -l /home/USER/usr/share/man/man1pidgin.1

    The -l argument tells man to open a manual page (and format it) for a custom file provided by the user.

    Now that Finch is properly installed, let's get to work. First, type finch in a console to fire it up:

    Navigation
    Finch is built using the ncurses toolkit, which is a library designed especially to built text user interfaces. To navigate in a Finch window, use Tab to focus the next widget (option, tickbox, button), Shift+Tab to focus the previous one, Space in order to tick/untick an option, and Enter to 'click' a button. You will also need to press Esc to exit from menus such as the Actions menu.

    The first time it starts, Finch automatically opens the accounts window, so you can now select the Add button and press Enter. In the window that appears - New Account - use the arrows to select the desired protocol, and then use Tab to navigate to the next field, fill it in with your data, and so on:

    Creating a new Yahoo! account

    Next, save your newly created account. Now, to close the Accounts window, press Alt+C. You should be now able to see your contact lists since Finch will try to automatically connect to the protocol you specified.


    New mail notification

    Now, before moving on to configure Finch, first let me list the most important keyboard shortcuts which are useful to navigate, customize and use this application.

    Moving around

    Alt+Q - just so you know this quits Finch, getting back to console

    Alt+A - opens the Actions menu, which contains everything you need to configure Finch: accounts, buddy lists, file transfers, plugins, sounds, preferences and statuses; use the Esc key to close this menu when you're done

    Alt+C - closes the currently opened window

    Alt+N - switch to the next window; you will need this to switch between chats, and other openend windows

    Alt+P - switch to the previous window

    Moving and resizing windows
    There are two important shortcuts here, which will help you to:

    1. Move windows in Finch
    For this, use the Alt+M keyboard shortcut. This will highlight the currently selected window so you will be able to use the arrow keys in order to move it anywhere inside the terminal; use Esc to deselect it when you're done.

    2. Resize windows in Finch
    Press Alt+R in order to highlight the currently selected window, then use the arrow keys to resize it; press Esc to deselect it when you're done.

    Configuring Finch
    To configure Finch, press Alt+A, which will open the Actions menu. Here you can edit accounts, enable/disable plugins or configure general Finch preferences. For now we will focus on the the Preferences entry:


    As you can see, you can configure the:
    - Buddy List - to turn on/off showing idle times or offline buddies
    - Conversations - to show timestamps or notify buddies when you are typing them a new message
    - Logging - the log format, which can be plain text or HTML (formatted), also which types of events to log
    - Idle - which will report idle time based only on the last time you typed something in Finch (anywhere in Finch) or since the last message you send; also the number of minutes before becoming idle

    Configure this to your liking. A little more about configuration options: they are kept in the same directory for both Finch and Pidgin, and changes done to one of them affect the other. The configuration files and the logs can be found inside the ~/.purple/ directory, where ~ is your home directory. Notice that .purple is a hidden directory, so make sure that your file manager will list those (or use ls -a in console to view them).

    Plugins
    Finch comes bundled with several useful plugins, like Buddy Notes, TinyURL or the Log Reader:


    To open the above window, press Alt+A and go to the the Plugins entry. Configure those as you wish.

    The ~/.gntrc file
    This file allows you to configure Finch in more detail, including colors for its interface, re-binding keys, change keys for various Finch actions, and even enable mouse support.

    Here's how to enable mouse support. Open up a text editor and edit (or create if it doesn't already exist - and it probably won't) the ~/.gntrc file:

    nano ~/.gntrc # or gedit ~/.gntrc

    Next, add the following lines in this file, then save it:

    [general]
    mouse = 1

    This is all. Notice that if the file is already created, you should find the section [general] and set the mouse option to 1 (true). Although the manual page says the mouse support is still experimental, I found no issues with it. However, manipulating Finch actually seems harder with a mouse after using it exclusively from the keyboard.

    Why use Finch at all?
    Well, don't if you want avatars and all the beauty a graphical client offers! Use Pidgin, Empathy, Kopete or something else! But if you need for some reason (speed, lack of memory etc) a terminal-based application for instant messaging, then give Finch a try.

    This should be all for today. I hope you'll enjoy Finch as much as I do!

    Further reading
    Don't forget man finch - it has all the info you need (and more about all the ~/.gntrc file, which couldn't be covered in this guide). The official homepage and guide:
    Using Finch
    Finch homepage
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Post to Twitter from Command-Line

    This is a short tutorial explaining how to post to Twitter using command-line in Linux, without needing to even open up your web browser.

    First, install the curl package:

    sudo apt-get install curl

    Next, create a script anywhere in your $PATH, for example twitter.sh inside ~/bin, where ~ is your home directory (make sure ~/bin is included in your $PATH variable, in case echo $PATH doesn't return it, edit ~/.bashrc and add a line like this: export PATH=/home/USER/bin/:$PATH).

    The script twitter.sh should contain the following:

    #!/bin/bash
    curl -u USER:PASS -d status="$*" http://twitter.com/statuses/update.xml > /dev/null
    echo "Message sent!"

    Replace USER and PASS with your Twitter username and password, and then make the script executable:

    chmod 755 ~/bin/twitter.sh

    And now test it:

    twitter.sh Hello, world! This is a test.

    So just use it as:

    twitter.sh YOUR MESSAGE

    This should be all. Have a look at the screenshots below:

    Running the twitter.sh script
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

10 Useful Linux Commands

    Here's a list of 10 commands which may come handy when using the command line in Linux:

    Search for all files modified in the last N days containing a specific text in their name

    find DIR -mtime -N -name "*TEXT*"

    For example:

    find ~ -mtime -5 -name "*log*"

    Will display all the files modified in the past 5 days which include the text 'log' in their filename.

    Determine which processes use the most memory

    ps aux | sort -nk 4 | tail

    Will show the first 10 processes which use the most memory, using ascendant sorting. Alternately:

    ps aux | sort -nrk 4 | head

    Will show the first 10 processes using most memory, using descendent sorting.

    Output of ps aux | sort -nrk 4 | head

    Display the username which is currently logged in

    whoami

    Show date using format modifiers

    date +"%H:%M:%S"

    Will output time in format HOUR:MINUTE:SECOND. You can use any format specifiers explained in the man page. The double quotes are required in case you need to use spaces.

    Showing date in format month, day year

    Show info about a specific user

    finger $USER

    Output of finger $USER

    Show disk usage separately for each partition

    df -h

    The -h switch will tell df to show human-readable sizes (KB, MB and GB when it is the case)

    df -B 1K

    Will show sizes in kilobytes.

    Show which modules are loaded

    lsmod

    Add or remove a module to/from the Linux kernel

    Insert a module:

    modprobe MODULE

    Remove a module:

    modprobe -r MODULE

    Search for a file using locate

    locate FILENAME

    Will search the locate database (created with updatedb) for any path or file which contains FILENAME.

    Change the encoding of a text file

    iconv -f INITIAL_ENCODING -t DESIRED_ENCODING filename

    For example:

    iconv -f ISO-8859-16 -t UTF-8 myfile.txt

    Will change the encoding of myfile.txt from ISO-8859-16 (Romanian) to UTF-8.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Tip of the Day: Format C Code Using Indent

    Indent is a powerful application developed by the GNU project, designed to format and change the appearance of C code. Indent will insert or delete whitespace characters to make your C code easier to read. It supports several code styles, including:
    - GNU indent style (which is the default, or indent -gnu)
    - Kernighan & Ritchie indent style (invoked with indent -kr)
    - original Berkeley indent style (invoked with indent -orig)

    Thus, to indent a C source file using the Kernighan & Ritchie style, one would use:

    indent -kr source.c

    Have a look at the screenshots below:

    Original, wrongfully formatted source code

    Same code, formatted using indent source.c (using default GNU style)

    Same code, formatted with the Kernighan & Ritchie style (with indent -kr source.c)

    Notice that indent is developed to work with C code, not C++; also, it will try to cope with invalid code too.Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Tip of the Day: Prevent Exiting a Shell with Ctrl+D

    A normal Bash shell with exit the current session when pressing ^D (Ctrl+D), but this can be avoided by editing the ~/.bashrc file and adding the following line:

    export IGNOREEOF=1

    This command will set the $IGNOREEOF variable to true, preventing a single combination of ^D to exit. In order to close the session, you can still use exit or double ^D.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Tip of the Day: Resize Images from CLI Using ImageMagick

    ImageMagick is a powerful set of tools used to perform various operations on images directly from the command-line. To install it in Debian type as root:

    apt-get install imagemagick

    Or in Ubuntu:

    sudo apt-get install imagemagick

    With the user password.

    Resize images using convert
    The tool we're going to need for this is convert, which is included in the imagemagick package. Here's one easy way to do it:

    convert -sample 50%x50% input_image.png output_image.png

    This will resize the input_image.png and make it half the original image.

    Another tool which does the same thing is mogrify, with the exception that it will overwrite the original image:

    mogrify -resize 320 filename.jpg

    This will resize filename.jpg using a width of 320 and keeping the aspect ratio intact.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Don't Start Unneeded Services on Start-Up in Debian

    By default, Debian uses run level 2, which means that in normal, multi-user mode Debian will automatically run scripts located in the /etc/init.d/ directory. But how does it do it? First, it will look in the corresponding directory of the run level, /etc/rcN.d/ (which, in the case of run level 2 will be /etc/rc2.d/) and run all the scripts which are pointed to by the symbolic links starting with letter S in this directory.

    So all the symbolic links in /etc/rc2.d/ actually point out to executable scripts in /etc/init.d/.

    If you perform an ls -l /etc/rc2.d you will see an output which can look something like this:
    As you can see, all of them are symlinks to scripts in /etc/init.d/. The links which start with a K will determine the respective script not to start, while the ones starting with S will run it with the start argument. All the scripts in /etc/init.d can be run as:

    /etc/init.d/script_name start|stop|restart

    Now, in order to prevent a daemon from running at system start-up, for example S20ircd-ircu (the ircu IRC server), all you have to do is rename it to a name which starts with K, then a two-digit number made up from the difference between 100 and the number which follows S, and then its name. For our example, that would be (as root):

    mv S20ircd-ircu K80ircd-ircu

    The next time you reboot your Debian box, the IRC daemon will not be started automatically, but you'll be able to rename it back to S20ircd-ircu or start it manually, as root, like this:

    /etc/init.d/ircd-ircu start

    A simple and clear explanation on how things work can be found in the files /etc/rc2.d/README and /etc/init.d/README.

    One of the popular uses of this is to prevent display managers from starting up, for example gdm or kdm:

    mv S99kdm K01kdm

    This will prevent kdm (KDE display manager) from starting up, leaving you at a shell login prompt. Useful when you only need a server, or want to live in command-line only for a while. To start it up, just use, as root:

    /etc/init.d/kdm start
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Nmap 5.0 Released - Biggest Release Since 1997

    Nmap 5.0 was released on July 17th 2009 and according to the official announcement, this is the biggest release since 1997.

    Nmap (or Network Mapper) is a powerful, complete, open-source tool for network exploration and port scanning.

    This release features many improvements, among which are the new Ncat tool for data transfer, redirection and debugging; the Ndiff scan comparison tool which reports changes between different network scans; the performance improved dramatically; the Nmap Scripting Engine allows users to write scripts to automate a wide variety of networking tasks. See the users' changelog here.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

5 Bash Tips, Part II

    This article is a continuation to my other Bash-related post, 6 Bash Productivity Tips. Since that article gathered many useful comments and I bumped into several more over the net, here are 5 more tips and tricks. Although these may not be necessarily productivity-related, they will surely ease working in a Bash terminal and it may be worth knowing them. If you're not familiar with the terminal, command-line interface and Bash you can go ahead and read my introduction to Linux CLI.

    Using Ctrl+R (reversed search)
    Ctrl+R performs a reversed search in the history. For example, typing the command df -h | grep /dev/sda1, then pressing Ctrl+R and typing only df, the most recent command will be auto-completed and performed upon pressing Enter. Ctrl+R searches for occurences of what you type and returns the last command in which it finds it:

    $ df -h | grep /dev/sda1
    /dev/sda1 83G 65G 14G 83% /
    (reverse-i-search)`df': df -h | grep /dev/sda1

    Using !COMMAND
    Where COMMAND is any command executed in the past or the beginning of a command. This calls the most recent command starting with COMMAND. For example:

    $ for i in *.ogg; do vorbiscomment -l $i; done
    ...
    $ ls
    ...
    $ !for
    for i in *.ogg; do vorbiscomment -l $i; done

    In the above example, using !for followed by Enter executed the last occurence in the history which started with for.

    Exit status: echo "$?"
    This will return the exit status of the last executed command. It can prove useful in scripts. A command returns 0 if it ended successfully and a non-zero value otherwise:

    $ cat /etc/motd | head -1
    Linux debian 2.6.26-2-686 #1 SMP Sun Jun 21 04:57:38 UTC 2009 i686
    $ echo "$?"
    0
    $ cat /etc/mots
    cat: /etc/mots: No such file or directory
    $ echo "$?"
    1

    Using !! with sudo
    Here's a useful example of !! from one of the comments in the older post. !! will replace the last command, so using sudo !! will execute the last command preceding it with sudo. Very useful when performing commands which need root privileges and forgetting to precede them with sudo. Example:

    $ apt-get update
    E: Could not open lock file /var/lib/apt/lists/lock - open (13 Permission denied)
    E: Unable to lock the list directory
    $ sudo !!
    sudo apt-get update

    Run a specified command in history with !NUMBER
    This will run command numbered NUMBER from history. Examples: !250, !1, etc. To view the history and the corresponding numbers, type history:

    $ history | tail -3
    534 for i in *.ogg; do vorbiscomment -l $i; done
    535 history
    536 history | tail -3
    $ !534
    for i in *.ogg; do vorbiscomment -l $i; done
    Error opening input file '*.ogg'.

    In the above example, command number 534 was executed when typing !534.

    For other suggestions or corrections to these tips, please use the comments below.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Tip of the Day: Make a Memory Usage Script

    Here's a simple memory usage script made in Bash, which will use the parsed output of free -tom utility. First, here is what the -tom argument stands for:

    -t displays a line containing the total amount of memory (physical memory + swap)
    -o disables the display of a buffer line
    -m displays sizes in MB

    Here goes the script, which outputs the total, used and free memory:

    #!/bin/bash

    # total memory
    memt=$(free -tom | grep "Total:" | awk '{print $2}')
    # used memory
    memu=$(free -tom | grep "Total:" | awk '{print $3}')
    # free memory
    memf=$(free -tom | grep "Total:" | awk '{print $4}')
    echo "Total memory: $memt MB"
    echo "Used memory: $memu MB"
    echo "Free memory: $memf MB"

    You can put this in a file of your choice, say memory.sh, make it executable (chmod 755 memory.sh), put it inside ~/bin (or a directory of your choice) and then include that directory in your $PATH, so you'll be able to run the script just by typing memory.sh.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Compile and Install Amarok 2.1.1 in Ubuntu 9.04

    Amarok 2.1.1 was released on June 17th and it includes several bug fixes and a few new features compared to 2.1. Among the new features worth mentioning: there is available support for compilations with over 60 artists, there is an option to hide the context view now. For a full list of changes and bug fixes, have a look at the announcement on the official website.

    Kubuntu 9.04 ships with 2.0, so to get the latest Amarok you can either use the PPA repository (which can be a little delayed) or compile from source. Here are the steps you need to follow in order to compile 2.1.1 from source:

    1. Install the development libraries
    In Konsole or GNOME Terminal, type:

    sudo apt-get build-dep amarok

    This will fetch and install the development packages needed to compile the latest Amarok release. Also, install these packages too:

    sudo apt-get install libtag-extras-dev libmysql++-dev libgdk-pixbuf-dev libgtk2.0-dev

    2. Get the source tarball
    Download the Amarok source tarball from here, then uncompress it:

    tar -xjf amarok-2.1.1.tar.bz2

    3. Compile and install Amarok
    You may need to remove your existing Amarok installation first:

    sudo apt-get remove --purge amarok

    (Notice that this will erase your entire Amarok settings, scripts, ratings etc. *Skip* this step if you want to keep those!)

    rm -rf ~/.kde/share/apps/amarok/
    rm ~/.kde/share/config/amarok*

    Then, make sure the current working directory is amarok-2.1.1 and type:

    cmake -DCMAKE_INSTALL_PREFIX=/usr
    make
    sudo make install

    For the last command you will need to enter your user password. This should be all, just fire up Amarok and 2.1.1 should be running now.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Compile and Install SMPlayer from Source in Debian Lenny

    SMPlayer uses the mplayer engine for displaying videos and it's one of the most powerful and popular video players out there. Built using the Qt 4 toolkit, SMPlayer offers great features and it's highly customisable.

    The latest version is 0.6.7, which brings experimental support for DVD menus and several other improvements and bug fixes over the previous release, 0.6.6. Here are several steps to follow in order to build SMPlayer from source in Debian Lenny:

    1. Enable the sources repositories
    Edit the /etc/apt/sources.list file as root with your favourite text editor (e.g. nano /etc/apt/sources.list or kdesu /etc/apt/sources.list) and make sure you have a line which starts with deb-src, as in the example below:

    deb-src ftp://ftp.ro.debian.org/debian/ lenny main contrib non-free

    You can replace the TLD with the one of your country (e.g. instead of ro use fi for Finland, de for Germany etc.) Next, update the packages list as root:

    apt-get update

    2. Install the needed dependencies
    As root, type:

    apt-get build-dep smplayer
    apt-get install devscripts

    This will install the tools needed to build SMPlayer and also the development libraries on which it depends.

    3. Download the source tarball and uncompress it
    Get the latest source for SMPlayer (which is 0.6.7 at the time of writing) from the official website (the file is called smplayer-0.6.7.tar.bz2). To uncompress it, make sure the current working directory is the one where you saved the source and type:

    tar -xjf smplayer-0.6.7.tar.bz2

    4. Compile and install SMPlayer
    Change the working directory to smplayer-0.6.7 and issue the commands:

    make QMAKE=/usr/share/qt4/bin/qmake

    And to install it type as root:

    make install

    This should be all. SMPlayer should be inside /usr/local/bin/smplayer.

    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

6 Bash Productivity Tips

    1. Use !!
    Typing !! followed by Enter will bring back and execute the last command (same as Ctrl+P followed by Enter).

    2. Use Emacs-like shortcuts
    Emacs-like shortcuts make use of the Ctrl and Alt keys, and the big advantage of navigating and manipulating text in a Bash prompt is that you won't have to move your fingers away from the typing position (to access the arrow keys, or the Home, Page Up and Page Down keys). Notice that most of those work well inside manual pages too, or when using the Nano editor, or the less and more pagers.

    Ctrl+D - or EOF (end-of-file) will quit the current Bash session
    Ctrl+P - bring back the last command executed
    Ctrl+N - bring the next command executed
    Ctrl+U - delete all from the cursor to the left
    Ctrl+K - delete all from the cursor to the right
    Ctrl+B - go back one character
    Ctrl+F - go forward one character
    Alt+B - go back one word
    Alt+F - go forward one word

    3. Make manual pages coloured
    I think this tip is a productivity tip because once a manual page is shown coloured, it is easier, clearer to read. Just add the following inside the ~/.bashrc file, where ~ is your home directory (notice that each line starts with export):

    export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
    export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold
    export LESS_TERMCAP_me=$'\E[0m' # end mode
    export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
    export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box export LESS_TERMCAP_ue=$'\E[0m' # end underline
    export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline

    Then, type:

    source ~/.bashrc

    And try any manual page (e.g. man bash). Here's how a coloured man page looks like using the presets above:

    Coloured man page

    4. Use your own scripts
    If you have basic knowledge of Bash scripting, you can create scripts and put them in a directory included in your $PATH. You can use something like ~/bin or ~/usr/bin, where ~ is your home directory.

    5. Copy/paste using Shift+Insert
    Although this one is not Bash-specific, it's very useful when you need to quickly copy/paste some text in your terminal. The same can be accomplished using the middle-click mouse button.

    6. Use aliases
    One of the powerful features of Bash is that it makes use of aliases. Those are usually short commands which perform some associated, longer command or commands. For example, to update and upgrade your Ubuntu installation you would type sudo apt-get update && sudo apt-get upgrade, and to create an alias for it you would only have to add something like the following inside the ~/.bashrc file:

    alias update='sudo apt-get update && sudo apt-get upgrade'

    Now, each time you type update, the command inside the single quotes will be executed.

    Have some other tips that others may find useful? Please share them in the comments below.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Compile and Install Kaffeine 0.8.8 in Debian Lenny

    Kaffeine is a powerful video player for KDE, using the Xine engine. The latest KDE3 release is 0.8.8, which fixes some bugs and introduces S2 support.

    These are a few steps to follow in order to compile Kaffeine on Debian Lenny (which ships by default with 0.8.7):

    1. Make sure the sources repositories are enabled
    Edit your /etc/apt/sources.list file as root (e.g. su; nano /etc/apt/sources.list) and make sure a line which starts with deb-src and looks like the one below is available:

    deb-src ftp://ftp.ro.debian.org/debian/ lenny main contrib non-free

    Next, update the sources lists:

    su
    apt-get update

    2. Download the source code
    Get the source from the official homepage, here, then uncompress it:

    tar -xjf kaffeine-0.8.8.tar.bz2

    3. Install the needed dependencies
    As root, type:

    apt-get build-dep kaffeine
    apt-get install libcdio-paranoia-dev

    The library libcdio-paranoia-dev is needed in order to get rid of the error ERROR: Could not find cdparanoia headers.

    This will install build-essential and the development libraries needed to compile Kaffeine.

    4. Compile and install Kaffeine
    Just follow the usual steps:

    ./configure
    make
    make install

    The last one as root. If you want to install Kaffeine as local user, use:

    ./configure --prefix=/home/USER/usr
    make
    make install

    No root required for the last command. This should do it.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Configure Bash to Show Some Info and Greet the User When Invoked

    In this tutorial I'll show how to add some message (or run whatever application, echo whatever text you wish) when you start Bash in a terminal application like GNOME Terminal or Konsole.

    When Bash is started in interactive way it will execute the commands found in ~/.bashrc, where ~ is you home directory. This file usually contains the PS1 variable (which holds the way the prompt looks like (by default this is user@host in most distribution), aliases, instructions to execute the /etc/bash_completion and ~/.bash_aliases files if found etc.

    In order to show some message when Bash starts we will add the commands we want executed at the end of this file, so edit it with your favourite text editor, e.g. nano ~/.bashrc and add something like this:

    fortune

    This command will echo some random quote from a database which has over 15.000 quotes. Notice that you will have to install the fortunes package, in example on a Debian system type as root:

    apt-get install fortunes

    You can add any command you want executed to ~/.bashrc, for example I have those:

    echo -ne "Hello, $USER! Today is $(date).\n\n"
    cal
    echo -ne "System Info: $(uptime)\n\n"
    echo -ne "Fortune of the Day:\n"
    /usr/games/fortune

    Here's a screenshot of the output for those commands:


    As you can see, first it echoes a message to the currently logged in user, it shows the date, invokes the cal application which will display a calendar, it shows the system uptime and then echoes a quote using the fortune game.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Compile and Install digiKam 0.10 in Debian Sid

    digiKam is a popular photo management application for both KDE3 and KDE4. Starting with version 0.10, digiKam offers a KDE4 port too. Here are instructions on how to compile from source and install the latest release in Debian Sid.

    1. Install the needed dependencies
    First of all, install the tools needed for the compilation. Type as root:

    apt-get install build-essential cmake

    Get the KDE4 development libraries too:

    apt-get install kdelibs5-dev

    Now, install the development libraries needed to compile digiKam (that's only one line):

    apt-get install libgphoto2-2-dev libkipi6-dev libexiv2-dev libkdcraw7-dev liblcms1-dev libtiff4-dev libpng12-dev libjpeg62-dev libjasper-dev

    These should do it.

    2. Download the source code
    Next, download the tarball from the official website and uncompress it:

    tar -xjf digikam-0.10.0.tar.bz2

    3. Compile and install digiKam
    Change the current working directory to digikam-0.10.0, then compile and install it using these commands:

    cmake .
    make
    make install

    The last one as root. This worked for me (I hope I didn't miss any dependencies, if so, please let me know.) DigiKam 0.10 should be now installed.
    Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Herrie Short Guide & Overview - Minimalistic Audio Player for Console

    Herrie is a small music player for console, based upon the ncurses interface. It features a simple interface with two panels, a playlist and a file browser. Herrie can play Ogg Vorbis and MP3 and also has AudioScrobbler (Last.fm) support.

    The shortcuts are a little bit non-intuitive, but man herrie will clear that out. In order to enter a directory or go up one level you will have to use the right and left arrows because the Enter key doesn't seem to work. To add the currently selected directory/track in the file browser to the playlist hit a, and to start playing use x. The same shortcut is used for pausing playing. Here are some useful shortcuts (notice that they are case sensitive, so D will mean press Shift+D):

    a - add current directory/filename to the playlist
    x - start playing
    c - pause/resume playing
    v - stop playing
    ( - decrease volume
    ) - increase volume
    / - search for entries
    n - search for next occurence
    D - remove all entries in the playlist (clear playlist); you'll be prompted to do it
    q - quit Herrie

    You can also use the typical h, j, k and l keyboard shortcuts for browsing through the file browser.

    Herrie will also add files which are not audio formats to the formats, this means whatever it finds in the directory added to the playlist.

    Usual interface of Herrie

    The global Herrie configuration file is located in /etc/herrie.conf, while the user-specific configuration file can be manually created as ~/.herrie/config, where ~ is your home directory. You'll need it when setting the Last.fm username and password.

    The good thing about Herrie is that it has Last.fm song submission support, which you can enable by editing (or creating if it doesn't already exist) the ~/.herrie/config file and adding the following two lines:

    scrobbler.username=USER
    scrobbler.password=PASS

    Replace USER and PASS with yours. Herrie also has an XMMS-like playlist mode, which can be enabled by adding the next line inside ~/.herrie/config:

    playq.xmms=yes

    You can also run Herrie as herrie -x and get the same result.

    One of the drawbacks of Herrie is that it won't read tags, not even for Ogg Vorbis files, so if your music collection has files which are called something like track01.ogg, track02.ogg and so on, that's what you'll get in the playlist too.

    I must admit Herrie is a little unusual and definitely the most unintuitive console player I've ever tried when it comes to the way you have to use it (especially keyboad shortcuts), but it can be a viable alternative to players like cmus, mp3blaster or moc once you get used to it.

    Related articles
    CMus Review - A Great ncurses Music Player
    Review: MOC, Text-Based Audio Player
    Several Powerful Console Music Players for LinuxSource URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

5 Popular Tricks to Customise Nano Editor


    Nano is a popular and user-friendly text editor for console which is mostly used for editing quickly configuration files, sources or various other text files. It does not compete with advanced development environments like Vim or Emacs, but it's fast and easy on resources.

    Here are five (popular, I hope) tips for customising Nano and changing its default behaviour.

    1. Enable auto-indentation
    When Nano starts, it reads a system wide configuration file which is usually located inside /etc/nanorc and executes the commands located inside it, then it searches for the user configuration file, located in ~/.nanorc, where ~ is the user's home directory. To configure Nano for your user, you only need to edit the ~/.nanorc file. Notice that since this is a hidden file, you may have to turn on hidden file view in your file manager, or use ls -a in a terminal.

    Edit the ~/.nanorc configuration file (create it if it doesn't exist; ~ is your home directory) and add the following line:

    set autoindent

    This will turn on auto-indentation for a new line to the same level of the previous line. Alternately, you can run Nano with the -i switch:

    nano -i

    Or just type Alt+I inside Nano when it's running.

    2. Enable syntax highlighting
    Edit the ~/.nanorc configuration file and add lines which go like this:

    include "/usr/share/nano/c.nanorc"
    include "/usr/share/nano/perl.nanorc"

    Default Perl syntax highlighting in Nano

    Several other default highlighting rules are found inside the /usr/share/nano/ directory. I wrote a full tutorial about enabling syntax highlighting in Nano here.

    3. Turn off the creation of backup files
    By default, Nano creates backup files with names like filename~ after editing a file. To turn this behaviour off, edit the ~/.nanorc file and add the line:

    unset backup

    To turn backup files on again, use set backup in the configuration file.

    4. Don't add newlines at end of files
    By default, Nano will add a newline character at the end of a saved text file. If you want this disabled, add the following option inside ~/.nanorc:

    set nonewlines

    5. Change tab size
    Nano uses by default 8 columns for the tab size. In order to change it to another value, say 4, use:

    set tabsize 4

    Or some other value depending on your needs.

    These are several settings I think are among the most popular. For a complete manual, use man nano, man nanorc and the official online manual.Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

How-To: Convert APE to Ogg Vorbis or MP3 in Debian and Ubuntu

    APE is an open-source, free lossless audio format, just like FLAC or WAV. APE is also known as Monkey's Audio. To convert it to either Ogg Vorbis or MP3, you will first need to install several packages:

    apt-get install monkeys-audio vorbis-tools

    The first package includes the mac tool, which is a command-line frontend to the APE decoder. vorbis-tools is the package required to encode to the free Ogg Vorbis audio format. I recommend this one over MP3, since it's completely free and usually all the players on Linux support it by default.

    Next, we will use the mac tool to convert the APE file(s) to WAV. For a single file, use the following command:

    mac audio_file.ape audio_file.wav -d

    For several files, use:

    for i in *.ape; do mac "$i" "$i.wav" -d; done

    Now all the APE files will be converted into WAV, which can be easily converted to Ogg Vorbis or MP3 using the commands below.

    Ogg Vorbis
    Convert WAV to Vorbis using the following command:

    oggenc -b 256 audio_file.wav

    Which will convert audio_file.wav to Ogg Vorbis at a nominal bitrate of 256 kbps. To convert more than one file at a time, use wildcards, e.g.:

    oggenc -b 256 *.wav

    MP3
    Still, for MP3 the lame utility is required, which is included in the debian-multimedia.org repositories for Debian and Medibuntu for Ubuntu. After adding those repositories to your /etc/apt/sources.list file and updated the package lists (apt-get update), install the lame package:

    apt-get install lame

    Now, to convert WAV to MP3, use:

    lame -b 256 audio_file.wav

    If you want to convert several WAV files at a time, use:

    for i in *.wav; do lame -b 192 "$i"; done

    Which will convert all the files with the .wav extension using a nominal bitrate of 192 kbps.

    If you're having trouble splitting a larger APE file with a CUE file, read this tutorial I wrote in the past.Source URL: https://ashesgarrett.blogspot.com/search/label/cli
    Visit ashes garrett for Daily Updated Hairstyles Collection

Blog Archive