Showing posts with label Arch. Show all posts
Showing posts with label Arch. Show all posts

Sunday, 20 July 2014

vrms (Virtual Richard M. Stallman)



I was intrigued by the sound of the vrms (Virtual Richard M. Stallman) program when I was surfing the web. It analyses the packages you have installed on your Linux machine and reports all of those that are non free. Originally developed for Debian you can get it on Arch from the AUR. If you use 'packer' you can simple install with :

$ packer -S vrms-arch

The program when run enumerates non-free packages which officially is "under licenses not considered by OSI, FSF, and/or the DFSG to be Free Software".

More info on the license categorization is found via

$ vi /usr/lib/python3.4/site-packages/vrms_arch/license_finder.py

List non-free packages and count 'ambiguously licensed packages that vrms cannot certify.'

$ vrms

Check all packages in locally synced package repositories (does not and cannot include the AUR), not just locally installed packages:

 $ vrms -g

The caveats with this method in Arch are because many packages in Arch, both free and non-free, use custom as the license field value. This means that it does not use an exact copy of one of the licences includes in the core licences packages which you can view under :

$ ls /usr/share/licenses/common/

Some common licenses like BSD and MIT are not included in the common licenses packages as they require to be edited for a specific project.

Desite these cavets I found it a useful tool to run on my various Arch systems!







Sunday, 13 April 2014

Empty Trash quickly from Command Line in Linux



I find it useful to be able to quickly delete the Trash on any Linux box I am working on. To do this is straight forward on Ubuntu, Linux Mint or Arch Linux.

Where Trash Resides

  • List your Trash files under :
$ ls -la ~/.local/share/Trash/
  • The 'files' sub-directory is the actual files 
  • The 'info' sub-directory is the metadata for each file
  • The 'expunged' sub-directory can have have content when a folder that belongs to you but contains files that don't is deleted

Manual Method 

  • You can manually remove :
 $ rm -rf ~/.local/share/Trash/files/*
 $ rm -rf ~/.local/share/Trash/info/*
 $ rm -rf ~/.local/share/Trash/expunged/*

trash-cli package

  • Recommended method
  • Install
$ sudo apt-get install -y trash-cli
  • Foe arch install from the AUR 
  • List trash contents
$ trash-list
2013-07-20 15:06:23 /home/lclark/tmp/experimental

  • Empty trash
 $ trash-empty
  • List contents and its empty
 $ trash-list
  • Enjoy !

Arch Linux on Raspberry Pi



After only using Raspbian on my Pi I wanted to try a different OS and as i've heard a lot of good things about Arch Linux decided to give it a try. I am using an SD card for the image.

Image Setup from Linux PC

 $ sha1sum archlinux-hf-2013-07-22.img.zip
e273d680e89ca9f79c2252c0b00ccc3084cd9b14  archlinux-hf-2013-07-22.img.zip

  • The long string can be compared with the SHA-1 given on the page the image was downloaded from
  • Extract image (img file will be ~ 1.9GB)
$ unzip archlinux-hf-2013-07-22.img.zip
  • Run command 
$ df -h
  • Connect SD card to your computer via dedicated port or SD card reader
  • Run command
$ df -h 
  • A new device will have appeared and this is the SD card to apply the image to shown in the left most column e.g.
 /dev/sdb1        56M   17M   40M  30% /media/cwishaw/3312-932F
  • For /dev/sdb1 the 1 refers to the partition number. We will format the whole disk e.g. /dev/sdb
  • Umount the device
$ sudo umount /dev/sdb1
  • Format SD card
    • bs = block size of 4MB 
    • if = image file downloaded and unziped
    • of = device name (important to get correct)
$ sudo dd bs=4M if=archlinux-hf-2013-07-22.img of=/dev/sdb
  •  Once format is complete (it may take a while) insert SD card into Raspberry Pi

Arch Linux on Pi

  • By default an IP will be obtained from DHCP and SSHD is enabled
  • Username : root
  • Password : root
  • The Pacman Rosetta guide is a great resource for Software Installations on Arch Linux

How to quickly install packages from the Arch Linux AUR


There are some amazing packages in the Arch Linux AUR (Arch User Repository) but its not amazingly obvious how to install a package.

  • Go to the AUR, search for the package you are interested in then select 'Download tarball'
  • Move the file to a folder to extract. I have a dedicated folder I use : 
$ ~/build/
  • Extract the file e.g.
$ tar xvzf ttf-ms-fonts.tar.gz
ttf-ms-fonts/
ttf-ms-fonts/PKGBUILD
ttf-ms-fonts/ttf-ms-fonts.install

  • Move to the folder
$ cd ttf-ms-fonts
  • Review the  PKGBUILD file as you may need to intall depanancies e.g. review line
depends=('fontconfig' 'xorg-fonts-encodings' 'xorg-font-utils')
  • Create the package with :
$ makepkg 
  • Install using pacman
$ pacman -U <NAME>.pkg.tar.xz

  • Example 
$ pacman -U ttf-ms-fonts-2.0-10-any.pkg.tar.xz



Arch Linux Diagnose Shutdown Problems



If your arch installation fails to shutdown correctly its important to find out if the issue is a kernel or systemd issue. To find this out try each of :

$ sudo sync && sudo reboot -f
$ sudo sync && sudo poweroff -f


If any of the two above commands do not work its a kernel and _not systemd issue.

For systemd issues fter boot run :

$ sudo systemctl --state=failed

Then see if any modules failed to load and work through each in turn.

One other potential issue is that your username is not part of the power group. Add user to group with :

$ sudo gpasswd -a <username> power

Then logoff/on to apply the new group and try to shutdown.







glances - a simple but cool monitoring tool







I always am on the lookout for tools to help with monitoring a diagnosing issues. The best tools I find are those that quickly show you the information you need to know in an easy to read manner. I just discovered the excellent tool glances which is a a cross-platform curses-based monitoring tool. It shows a lot of useful information but in a manner that is easy to read. It can even be used in client/server mode!

Information shown includes :

  • Disk Usage per mount point
  • Disk I/O
  • Network Rx/s + Tx/s
  • Memory Usage
  • CPU Usage
  • Process
  • Uptime
I really like that it has color codes for state :

  • Green : OK
  • Blue : Careful
  • Magenta : Warning
  • Red : Critical

Installation



Arch Linux

  • From standard Arch or Raspberry Pi based ARM :

$ pacman -S glances

Ubuntu (13.04+)

  • From standard apt-get :

$sudo apt-get -y install glances


Debian/Ubuntu (pre 13.04)

  •  From python's 'pip'

$ sudo apt-get install python-pip python-dev
$ sudo pip install glances

CentOS/Red Hat

  • Configure the EPEL repository
  • Then install via yum

# yum -y install glances


Refresh Time

  • The default is 3 seconds but this can easily be changed e.g.
$ glances -t 10

Interactive Commands


  • a : Sort process list automatically
  • b : Switch between bit/s or Byte/s for network I/O
  • c : Sort processes by CPU usage
  • d : Show/hide disk I/O stats
  • f : Show/hide file system stats
  • h : Show/hide the help screen
  • i : Sort processes by I/O rate
  • l : Show/hide log messages
  • m : Sort processes by MEM usage
  • n : Show/hide network stats
  • p : Sort processes by name
  • q : Quit
  • s : Show/hide sensors stats (only available with -e flag)
  • t : View network I/O as combination
  • u : View cumulative network I/O
  • w : Delete finished warning log messages
  • x : Delete finished warning and critical log messages
  • y : Show/hide hddtemp stats (only available with -y flag)
  • 1 : Switch between global CPU and per-CPU stats
     

 Client/Server mode


  • In the server :

$ glances -s
Glances server is running on 0.0.0.0:61209


  • On Client
 $ glances -c @server

  • The footer will display the connection information e.g. Connected to @pi is shown below


Quickly Switch between ChromeOS and Ubuntu or Arch Linux


If you have a Chromebook and use it for a 'traditional' Linux rather than the default OS its really useful to be able to switch between your Linux OS (e.g. Ubuntu or Arch) and the Google ChromeOS. The easiest way I have found for this is to use aliases.

Ubuntu or Arch Linux

Use a text editor to update your ~/.bashrc or ~/.bash_alias file e.g.

alias ChromeOSBoot='sudo cgpt add -i 6 -P 0 -S 1 /dev/sda && sync && sudo reboot'

Save the file. Reload .bashrc file with

# . .bashrc

Run the alias :

# ChromeOSBoot

This will then reboot the Chromebook into ChromeOS.

ChromeOS

To switch back to Ubuntu or Arch Linux do not login when prompted as the ChromeOS boots. At the login screen select 'Ctrl + ALT+ F2' then login as chronos user (no password).

Use vim to create a .bashrc file if it does not already exist e.g.

alias ArchOSBoot='sudo cgpt add -i 6 -P 5 -S 1 /dev/sda && sudo reboot'

Save the file. Reload .bashrc file with

# . .bashrc

Run the alias :

# ArchOSBoot

This will then reboot the Chromebook into Arch Linux (or Ubuntu if that's what you have installed).