Useful Linux howtos

Applications

  • to install Oracle Java JDK follow these instructions;
  • to compare files or directories use “Meld Diff Viewer”. You can install it by running:
    sudo apt-get install meld
  • to install Microsoft’s Core Font package run:
    sudo apt-get install ttf-mscorefonts-installer
  • to synchronize folders, files and make backups use “Conduit Synchronizer”. You can install it by running:
    sudo apt-get install conduit
  • to change grub settings (e.g. to change your default operating system, etc) install “StartUp Manager” by running:
    sudo apt-get install startupmanager
  • to automatically mount at boot your NTFS partitions install “Storage Device Manager” by running:
    sudo apt-get install pysdm
  • to set up a repository cache on your network so that once a package is downloaded from an official repository, all other machines will download it from your local area network, install squid-deb-proxy (and its client so the server downloaded updates get cached by the squid proxy and will also allow the server to install already-fetched updates via the proxy) on your server machine by running:
    sudo apt-get install squid-deb-proxy squid-deb-proxy-client

    then reboot your server machine. Clients can auto-discover caching-enabled machines in the local network by having the squid-deb-proxy-client package installed. To do that simply run:

    sudo apt-get install squid-deb-proxy-client

Information

  • to know your IP address:
    ifconfig | grep Bcast
  • to know your hardware details and save them in an html page run:
    lshw -html > your-file-name.html

    (a good idea is to generate one for each of your computers and save them up for future reference)

  • to check whether a certain package is installed:
    dpkg -l | grep packagename
  • to know whether you need to reboot a machine after updating the system via terminal check if the following file exists:
    /var/run/reboot-required
  • to test the speed of your hard drive run:
    sudo hdparm -t /dev/sd?
  • to list running services run:
    sudo netstat -tulpn
  • to check RAM speed, size and frequency:
    sudo dmidecode --type 17 | more
  • to know your processor details run:
    cat /proc/cpuinfo | grep name
  • to know the bios version of your motherboard run:
    sudo apt-get install smbios-utils
    sudo smbios-sys-info
  • to know the name of the Linux distribution installed on your machine run:
    lsb_release -a

    or, if that doesn’t work then run:

    cat /etc/issue
  • to have some system information of your machine run:
    uname -a
  • to see if your operating system architecture is 32-bit or 64-bit run:
    file /sbin/init
  • to list all users in your system from terminal, run:
    cat /etc/passwd | grep "/home" |cut -d: -f1

Operations

  • to configure your terminal commands history add one or more of the following lines to your ~/.bashrc file:
    • to change name of the file in which command history is saved:
      export HISTFILE=

      (the default value is ~/.bash_history)

    • to not save in the history certain command lines add them as a colon-separated list:
      export HISTIGNORE=
    • to not save a line matching any other previous entry in the history:
      export HISTCONTROL=ignoreboth
    • to change the number of commands to remember in the command history:
      export HISTSIZE=500

      (the default value is 500)

  • to add aliases system-wide you need to edit the file /etc/bash.bashrc For example, the following alias will provide a comprehensive update and clean operation:
    alias apt-update='sudo apt-get -f install
    && sudo apt-get autoremove -y
    && sudo apt-get autoclean -y
    && sudo apt-get clean -y
    && sudo apt-get update 
    && sudo apt-get upgrade -y --fix-missing'
  • to boot in text mode instead of graphical mode (GUI) open the /etc/default/grub file, locate the following line:
    GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash“

    and change it to:

    GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash text“

    and don’t forget to run ‘update-grub’ afterwards to update. If you need the graphical interface you can still have it by simply running “startx” once logged in.

  • to keep your computer’s time accurate follow these instructions;
  • to install fonts for system-wide run:
    mkdir /usr/share/fonts/truetype/myfonts
    cp [fonts] /usr/share/fonts/truetype/myfonts
    fc-cache -f -v
  • to add a new user via terminal run:
    sudo adduser username
  • to add a group to a userrun:
    sudo adduser username groupname
  • to modify the groups of a userrun:
    sudo usermod -G comma,separated,list,of,groupnames username
  • some useful command line shortcuts:
    • Ctrl-D: exit from the current session;
    • Ctrl-R: searching through the command history;
    • Ctrl-A: moves the cursor to the beginning of the command line;
    • Ctrl-E: moves the cursor to the end of the command line;
    • Ctrl-W: deletes the word immediately before the cursor;
    • Ctrl-K: deletes everything immediately after the cursor;
    • Ctrl-Y: undo a deletion.
  • to start a terminal maximized use the command
    gnome-terminal --window --maximize
  • to start a terminal in full screen use the command
    gnome-terminal --full-screen
  • to copy multiple files using scp use it like showed below:
    scp {file1,file2,file3} user@destination:~/
  • to speed up the ssh connection add “UseDNS no” (without quotation marks) at the end of your /etc/ssh/sshd_config and then run:
    sudo /etc/init.d/ssh reload
  • to add a new resolution to your monitor/display/screen run (assuming you want to add 1600×900):
    cvt 1600 900

    that will output something like this:

    Modeline "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync

    Copy the text following Modeline and paste it in the following command:

    xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync

    Then run the command xrandr alone:

    xrandr

    and note down the connected primary video source (should something like VGA-0, or VGA1). Supposing it’s VGA-0 then run:

    xrandr --addmode VGA-0 "1600x900_60.00"
  • to open/extract an eml file install munpack:
    sudo apt-get install mpack

    then run:

    munpack filename.eml -t
  • to chmod 775 sub-directories, files excluded:
    find /path/to/base/dir -type d -exec chmod 775 {} +

    to chmod 664 files recursively, sub-directories excluded:

    find /path/to/base/dir -type f -exec chmod 664 {} +

Leave a Reply

Your email address will not be published. Required fields are marked *