Useful Unix/Linux commands

Standard
$ indicates terminal command
# indicates a comment
Bold indicates “not installed by default”
$ lsusb     #list USB devices
$ lspci     #list all PCI devi
$ startx    #initialize an X session
$ more      #filter for paging through text one screenful at a time. (less gives more advanced).
$ less      #opposite of more; allows backward movement in the file as well as forward movement.
$ stty      #change and print terminal line settings
  $ stty size # prints terminal size

File commands

$ locate            #find files by name (for newbies I suggest the gui catfish -requires installation)
$ find              #search for files in a directory hierarchy
$ ls                #list directory contents
$ cd                #change directory
$ pwd               #print name of current/working directory
$ cp                #copy files and directories
$ rm                #remove files or directories
$ rmdir             #remove empty directories
$ file foo.format   #extracts info about file and what software it was written with; helpful in the case of having forgot which software was used to produce such a file

System info

$ uname
$ df                         #report file system disk space usage
                             #e.g; df or df /home
$ man                        #interface to the on-line reference manuals
$ free                       #Display amount of free and used memory in the system
                             #e.g; free -mt (m for MB & t for totals line)
$ uptime                     #tell how long the system has been running.
$ finger                     #user information lookup program
$ w                          #show who is logged on and what they are doing.
$ whoami                     #print effective userid
$ cat /proc/meminfo          #memory info
$ cat /proc/cpuinfo          #cpu info
$ lsb_release -a             #print (a: all ) distribution-specific information
$ last -x | grep shutdown    #show listing of last 10 logged in users; you can pipe this to the tail to read the last n instances.
                             #e.g; for 10 instances: last -x | grep shutdown | tail -n 10
$ last -x | grep reboot      #show listing of last logged in users
$ sudo shutdown -P hh:mm     #shutdown & poweroff (-P) @ hh:mm

Processes

$ uname
$ ps               #report a snapshot of the current processes.
$ top              #display Linux tasks
$ htop             #interactive process viewer based on top
$ watch            #execute a program periodically, showing output fullscreen
                   #e.g; watch -n 5 free -m
$ powertop         #program to analyze power consumption on Intel-based laptops
$ kill pid         #send a signal to a process
$ killall proc     #kill processes by name
$ pidof program    #find the process ID of a running program

Some useful terminal shortcuts

Ctrl+C #halt the current command
Ctrl+Z #pause command
$ fg #resume paused command in foreground bg resume paused command in background
Ctrl+D #logout of current session (similar to exit)
Ctrl+W #erase last word before cursor
Ctrl+U #erases the whole line
Ctrl+R #type to bring up a recent command
I hope this list turns out to be useful to you 🙂

Thanks for reading

last update: 2014-11-03

Take care of your eyes at the screen with Redshift

Standard
Before Redshit I was using f.lux [1] which seems to be broken in Ubuntu’s Unity. I searched for an alternative & found positive reviews about Redshift, which is inspired by f.lux.
By default, redshift fetches your approximate location using the internet (geoclue method) & uses it. if you prefer to manually set it, check the help. And if you, like me, prefer it to use a preset location &/or other configuration (without having to do it every time you run your system), create a text file named redshift.config under your ~/.config/ directory. You can do this from the terminal:
cd ~/.config/
gedit redshift.config
In this file, copy & edit the content below:

;This is a configuration file for the screen color temperature adjuster Redshift.

;Copy this file to your ~/.config/ directory for redshift to use.
;All lines starting with a semicolon areignored (e.g, adjustment-method).
;To change your location, edit the lat & lon numbers. If these two lines are set to be ignored, redshift will fetch your location using the internet.

; Global settings
[redshift]
temp-day=5700
temp-night=3500
transition=1
gamma=0.8:0.7:0.8
location-provider=manual
;adjustment-method=

; The location provider and adjustment method settings are in their own sections.
[manual]
lat=-22.871114
lon=-43.202591
Make sure to edit the numbers in the last two lines to correspond to your location, before saving & exiting the editor.
This way, every time redshift runs, it uses this configuration file. If you want it to automatically run on startup, add it to your Startup Applications (command: gtk-redshift for the gui & redshift for the cli).
Unlike f.lux, redshift only has a “toggle” option in the gui. The toggle toggles redshift on/off in case you need to. Other preferences are edited from within the configuration file or from the terminal.
 I’d like to thank the the code author, Jon Lund Steffensen, for making this tool; It is, to my knowledge, the only alternative to f.lux for Linux.
That’s basically it for now. May your eyes stress less while you work!

Thanks for reading

Linux: What is it & why? (vids)

Standard

Compiling Muesli Fortran

Standard

Here is the code you need to compile and install the free numerical and graphical MUESLI library, developed by Édouard Canot [1].

sudo apt-get install 'libatlas-dev liblapack-dev zlib1g-dev libreadline6-dev imagemagick  
libx11-dev libpng12-dev g++ gfortran' #installing dependencies
 Note: for Ubuntu 10.04 replace “libatlas-dev” by “libatlas-headers”)
tar xvfj muesli-linux-all-2.6.3_2012-05-03.tar.bz2 #untar

cd muesli-linux-all-2.6.3_2012-05-03/GNU_GFC
./configure --f90=gfortran --blas=/usr/lib/ --lapack=/usr/lib/lapack/ #configuring

make -s distclean #clean your distribution from previous installation
make -s (or for detailed output: make MODE=verbose) #compiling; this will take some time

cd tests #testing
make #make the test files
./run_all #run all the made test files

cd ..
make install #installing

cd tests/fgl #testing fgl
make #make the test files
./run_all #run all the made test files


And here’s a video on how to do that [1]:

For further help, please contact MUESLI’s author from the respective homepage [2].

==========================
[1] http://playterm.org/r/compiling-muesli-fortran-on-ubuntu-1336936852
[2] MUESLI library homepage: http://people.irisa.fr/Edouard.Canot/muesli/

Ubuntu 12.04 & Cinnamon

Standard
Hello again,

Precise Pangolin

Those who will try Ubuntu 12.04 & have a multitouch touchpad will notice the new feature (when enabled)!
Some not very apparent new features (relative to 10.04 & not 11.04 or 11.10!) are:
  • Installation time (i.e; start of copying files to notification or required reboot): 6~7 minutes.
  • Properties of an image in the image viewer gives you the folder name the image is located in & the ability (which I like) to open this folder by clicking the name.
  • Two-finger scrolling: In the “Mouse and Touchpad” settings, under Touchpad I enabled horizontal scrolling (which I do not understand why it is not enabled by default) & chose “Two-finger scrolling” instead of “Edge scrolling”. The latter was not comfortable in my case; I sometimes couldn’t lock the scroll & use it, but with the two-finger option (which needs some time to get used to) is much better; I can now use two fingers anywhere on the pad to scroll not just verticall or horizontally but in any direction (i.e; both vertical & horizontal).

Cinnamon

I’d also like share with you the relatively new desktop graphical user interface (GUI): Cinnamon. Below are two images of the desktop, which unlike Gnome 2 which has two panels, has only one main panel.
Cinnamon might very well appeal to Gnome 2 users who do not wish to switch to neither Gnome 3 that Fedora employs nor Ubuntu’s new Unity.
A particular feature employed in Cinnamon that adds to Gnome 2 that I really appreciate is a graphical feature. What I really like is the Mac-like drop-down window when saving a file. All I can show you is the screenshots below:
Cinnamon
The default GUI for Mint 12 with its default one-panel look.
Cinnamon panel settings
Cinnamon panel settings
It is very easy to edit the panel settings &/or add a new panel.

If you like what you see & would like to try it out, you can install it on Precise Pangolin (12.04 LTS) as follows (read note below first):

Note: Keep in mind that Cinnamon is a newly born project & so it is under active development &  you might possibly face bugs (but keep in mind ithat it has already the default for Mint 12). It deserves to be tried; Note that the above ppa is the “stable” repository.
Personally, I guess It is going to be second after Unity, though I am also testing LXDE, XFCE, fluxbox, openbox,…
Update (2012-06-05): For more about Cinnamon, check the article “Cinnamon 1.4” by Tim Schürmann and Kristian Kißling from Linux Magazine.

If you really enjoyed Cinnamon, I highly suggest that instead of installing Ubuntu & Cinnamon that you install the Ubuntu-based Linux Mint (or its other alternative, the Debian-based Linux Mint Debian Edition -LMDE).

Thanks for reading 🙂