Author: sotech

  • How to delete the rest of a line after the cursor in vim?

     

    Vim has a host of really useful shortcuts; the one we are looking at today allows you to delete the text on the same line after the cursor position. To do this, move the cursor to the desired position and hit:

     

    shift+d

     

    In other words, a capital D. We don’t need a colon in front of it. This will delete the remainder of the line.

  • Ubuntu: How to disconnect a telnet session

     

    If you haven’t used telnet much you might expect ctrl+c or ctrl+d to cancel a command and return you to the prompt. Try instead:

     

    ctrl+]

     

    Once you are back at the telnet prompt you can exit back to your shell using ctrl+d.

  • GIMP: How to save as .jpg and not .xcf?

     

    This is a question we get asked a lot from people who are trying out GIMP as a Photoshop alternative. If you hit Save or Save As, you are only presented with the option to save as a .xcf file. To save the image you are working on as a .jpg we need to export it instead:

     

    File->Export As

     

    You can use the following keyboard shortcut to do this:

     

    Shift+Ctrl+E

     

    Now you can save the image as a .jpg rather than the (usually unfamiliar to people trying it out) .xcf format.

  • Subsonic on Ubuntu: How to upgrade from 4.8 to the new 4.9 release

     

    Subsonic 4.9 is out! The installation instructions page doesn’t explicitly say anything about upgrading from a previous version – fortunately, though, you don’t need to do anything different. First, grab the .deb file – currently this works:

     

    wget http://aarnet.dl.sourceforge.net/project/subsonic/subsonic/4.9/subsonic-4.9.deb

     

    Install:

     

    sudo dpkg -i subsonic-4.9.deb

     

    If you have an existing 4.8 install you will see the following:

     

    Preparing to replace subsonic 4.8 (using subsonic-4.9.deb) …

     

    And you’re done! Reload Subsonic in your browser window or app and enjoy the new version. To see the new features since 4.8 you can view the changelog here:

     

    http://www.subsonic.org/pages/changelog.jsp

     

     

  • Ubuntu: How to see information about your system’s CPU

     

    To find out information about the CPU used in the system, we can use the following command:

     

    lscpu

     

    This gives us useful information about the CPU, such as the number of physical cores, virtual threads, virtualization support and more. An example output from a Haswell Xeon system looks like:

     

    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                8
    On-line CPU(s) list:   0-7
    Thread(s) per core:    2
    Core(s) per socket:    4
    Socket(s):             1
    NUMA node(s):          1
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 60
    Stepping:              3
    CPU MHz:               800.000
    BogoMIPS:              6784.21
    Virtualisation:        VT-x
    L1d cache:             32K
    L1i cache:             32K
    L2 cache:              256K
    L3 cache:              8192K
    NUMA node0 CPU(s):     0-7

     

    The above CPU is a Xeon E3-1245V3. The CPU speed reading as 800MHz is correct – this is the speed that Intel’s Speed Step technology drops the CPU down to to conserve power when the system is idle.

     

    This command can be really useful when you’re using an unfamiliar system or a virtual machine where you’re not sure what hardware – or virtual hardware – lies beneath the OS.

  • Ubuntu: Viewing all available block devices or hard drives, their mount point and their filesystems

     

    To list the available hard drives (to be specific, available block devices) we use the following command:

     

    lsblk

     

    This will provide output in the following format:

    NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    xvda    202:0    0     8G  0 disk
    ├─xvda1 202:1    0     7G  0 part /
    ├─xvda2 202:2    0     1K  0 part
    └─xvda5 202:5    0  1022M  0 part [SWAP]

     

    If you want to see the filesystems available on these block devices, we use the f flag:

     

    sudo lsblk -f

     

    If we don’t run this as root it won’t display the filesystems. The output looks like:

     

    NAME    FSTYPE LABEL MOUNTPOINT
    xvda
    ├─xvda1 ext4         /
    ├─xvda2
    └─xvda5 swap         [SWAP]

     

    There’s quite a bit of information in the above two outputs – we can see the block devices, their partitions, the mount points, the filesystems, their size and whether the partition is marked as readonly or not.

     

  • Ubuntu: Viewing past dmesg outputs from previous sessions

     

    Sometimes you may want to check the output of dmesg from a previous session. This can provide some useful information – for example, whether an error has only just started appearing or whether it was present during previous sessions. Ubuntu archives old dmesg outputs in the following location:

     

    /var/log

     

    We can see how many are there with the following command:

     

    ls -l /var/log/dmesg*

     

    This should output a listing similar to this:

     

    -rw-r—– 1 root adm 17169 Jan 10 17:07 dmesg
    -rw-r—– 1 root adm 17170 Jan  9 20:28 dmesg.0
    -rw-r—– 1 root adm  6063 Jan  9 20:22 dmesg.1.gz
    -rw-r—– 1 root adm  6076 Jan  4 22:36 dmesg.2.gz
    -rw-r—– 1 root adm  6108 Jan  4 22:27 dmesg.3.gz
    -rw-r—– 1 root adm  6105 Jan  3 14:16 dmesg.4.gz

    You can see that the old archives are compressed. To view the compressed files without decompressing them into the folder, we use the zless command. To do so with the first archive:

     

    sudo zless /var/log/dmesg.1.gz

     

    If you aren’t familiar with less you press ‘q’ to quit and return you to your prompt.

     

  • Fedora 20 – How to make SSH automatically start on boot (sshd.service)

     

    If you are coming to Fedora from Ubuntu you may be surprised that installing the package doesn’t automatically start the SSH daemon on boot. We can change this with the following command, run as root:

     

    systemctl  enable sshd.service

     

    The next time you boot your SSH server should have started automatically.

  • Fedora 20: Installing packages

     

    To install a package on Fedora via the command line, we use the yum command like so:

     

    yum install [package]

     

    Using tmux as an example:

     

    yum install tmux

     

    Loaded plugins: langpacks, refresh-packagekit
    Resolving Dependencies
    –> Running transaction check
    —> Package tmux.x86_64 0:1.8-3.fc20 will be installed
    –> Finished Dependency Resolution

    Dependencies Resolved

    ===========================================
    Package        Arch             Version                 Repository        Size
    ===========================================
    Installing:
    tmux           x86_64           1.8-3.fc20              fedora           243 k

    Transaction Summary
    ===========================================
    Install  1 Package

    Total download size: 243 k
    Installed size: 558 k
    Is this ok [y/d/N]:

     

    You can see that the yum command provides some useful information about the package you have asked it to install. If you are happy with the information provided you can install with “y” or cancel with “n”.

  • Fedora 20: Updating via the command line

     

    Fedora, unlike Ubuntu with apt-get, uses yum to update it’s software. Run the following as root (either by logging in as root or using su in front of the command):

     

    yum update

     

    You will see a list of the updated packages and a confirmation at the end. On our test system it looks like this:

     

    Transaction Summary
    ============================================
    Install   3 Packages (+  6 Dependent packages)
    Upgrade  97 Packages (+157 Dependent packages)

    Total size: 332 M
    Total download size: 275 M
    Is this ok [y/d/N]:

     

    If you are happy with the listed upgrades and/or new installations hit ‘y’ to update!