Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts

Removing old package for Linux Mint

To remove the orphaned dependencies using apt-get
# apt-get autoremove

To clean old versions of packages using apt-get
# apt-get autoclean

To remove all packages files from the acahe using apt-get
# apt-get clean

Using XrandR to control video projector

This is the 2nd part of my entry of xrandr. I have written a previous entry Using xrandr to change screen resolution and orientation

This blog entry essentially is to how how we can control monitor and projector.


Note 1: Firstly do a query on the connected port (ie projector)
# xrandr --query (You should be able to get your graphics output status whether it is VGA, HDMI etc)


Note 2: Setting the best resolution for the connected port (ie projector)
# xrandr --output VGA --auto


Note 3: Cloning mode for both internal monitor (DVI) and external projector (VGA)
# xrandr --output VGA --mode 1024x768 --same-as DVI --output DVI --mode 1024x768


Note 4: Switching Off the Video Projector and turn off the Internal Monitor
# xrandr --output VGA --off
# xrandr --output DVI --auto


Further Readings:

Installing Java Runtime Environment (JRE) from the command line on Linux Mint

If you are planning to install JRE and the web browser plugin, you will need to do the following:

# apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

Using Preload to boot startup and general performance for Fedora

Preload is a daemon that analyses what you do and fetches the binaries you're mostly likely to use to boost starup and general performance. To make a very superficial comparison, it is similar to Windows Superfetch

Note 1: To install preload on Fedora 11
# yum install preload

Note 2: To tweak the preload configuration, you can tweak the
# /etc/preload.conf
(the default value should work well for all most users)

Note 3: To view the log file of the preload daemon
# less /var/log/preload.log

Note 4: If you wish to take a look on what Preload is caching for you, you go to
# /var/lib/preload/preload.state

Note 5: To ensure that the preload daemon is startup everytime
# chkconfig --level 35 preload on

Automatically load sessions with SSH

To run a program after the ssh, simply pass the program at the end of the ssh command
# ssh root@remote.server.com nano

To connect into a remote screen session, it is necessary to add the "-t" flag
# ssh -t root@remote.server.com screen -dr
According to the ssh man page, the "-t" flag force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine.

For the screen command "screen -dr", it refers to reattaching a session and if necessary detach it first.

Very useful indeed

Force Rebooting Remotely without corrupting the file system

Must thanks to Gavin W. Burris for his interesing blog Remotely Force a Reboot which hightlighted Magic SysRq as a cool tool to force a reboot remotely.

Step 1: To enable SysRq key
# echo 1 > /proc/sys/kernel/sysrq

Step 2: Power cycle the machine
echo b > /proc/sysrq-trigger

For more information, read Wikipedia Magic SysRq

Using read-edid to extract useful information on PnP Monitor on Ubuntu or Linux Mint




Read-edid utility is a useful tool to help you  extract useful information on PnP Monitor.

According to the read-edid website, if you can't find the data to set your monitor up under XFree86, then read-edid is for you; it should auto detect all necessary info and should even provide a few modes with better refresh rates/resolutions than the standard VESA ones. However, as of now it won't do everything for you; you'll have to edit XF86Config yourself.

To install read-edid utility in Ubuntu or Linux Mint, just do a
# aptitude install read-edid OR
# apt-get install read-edid


The  data obtained by get-edid is in a binary format, so the parse-edid command is available to interpret  it  and  generate  a  human-readable block  of  text  information  that  can  also be included in an XFree86 XF86Config file. It is customary  to  invoke  get-edid  and  parse-edid  together  in  a pipeline.
# get-edid | parse-edid


More information:
  1. Get-edid Website

Prevent non-users from login into the system

Sometimes as administrator, you may need to some immediate repair work and need to prevent users from logging in immediately, you can easily do that by doing the following:

# touch /etc/nologin

If the file exists, only the root can gain accessnow

Using Ganglia Status Client - gstat

Ganglia Status Client (gstat) connects with a Ganglia Monitoring Daemon (gmond) and output. It is a clean command line tool

To see all the gstat Options
# gstat --help

Shows CPU utilization for running jobs
# gstat -al1

For more inforamtion See Ganglia Toolkit

Using Powertop to save Battery Power (Part 2)

Continuing from the entry Using Powertop to save Battery Power (Part 1)

How do we reinstate the optimised settings for ac-power? I suggest we put the settings that take advantage of AC-Power back into the /etc/acpi/ac.d

# cd /etc/acpi/ac.d # touch 16.optimsation.sh
# chmod 755 16.optimsation.sh
# vim 16-optimisation.sh

#------------------------------------------------------
echo 500 > /proc/sys/vm/dirty_writeback_centisecs
echo 0 > /proc/sys/vm/laptop_mode
hal-disable-polling --device /dev/scd0 --enable-polling
ifconfig eth0 up
iwpriv eth1 set_power 1
#-------------------------------------------------------


For more tips on the settings, do visit the Tip and Tricks session under LessWatts.org

Wiping Data Permanently from the command line

Learned this from the Tip and Tricks from Linux For You Magazine August 2010 Edition

Do be careful when you fire this command as this will destroy all your data. You should use the utilities shred

# shred -v -n 2 -z /dev/sdc
where
-v: verbose
-n: number of passes of random data
-z: finishes cleaning with one pass of zero

iotop - Identifying the process with the I/O

iotop is a cool tool to help identify process with the corrsponding I/O in a top-like UI.

This python program needs a Linux Kernel of > 2.6.20 with TASK_DELAY_ACCT and TASK_IO_ACCOUNTING options enabled. In addition, it requires python >= 2.5

To install on Linux Mint
# apt-get iotop

How to use iotop

Note 1: Show process that are causing I/O now
# iotop -o

Note 2: iotop in batch mode
# iotop -o -b -d20 -n30 > check-io.txt
  • -o (show process that are causing I/O only)
  • -b (Turn on interactive mode. Useful for logging I/O usage over time)
  • -d (delay or interval of 20 sec)
  • -n (number of iteration before quiting)

More information:

libibverbs: Warning: RLIMIT_MEMLOCK is 32768 bytes. This will severely limit memory registrations.

We are using OpenFarics for our HPC. According to the FAQ, "With OpenFabrics (and therefore the openib BTL component), you need to set the available locked memory to a large number (or better yet, unlimited) -- the defaults with most Linux installations are usually too low for most HPC applications that utilize OpenFabrics"

libibverbs: Warning: RLIMIT_MEMLOCK is 32768 bytes.
This will severely limit memory registrations.

For the solution, look here at http://www.open-mpi.org/faq/?category=openfabrics#ib-locked-pages
Or you can also look at my blog entry Encountering Segmentation Fault, Bus Error or No output

rsync with the soft-links

Simple entry for today.
I was trying to rsync 1 server to another server. To ensure that the symlinks are copy across as symlinks, do the following:

# rsync -rvl /opt/intel server2:/opt/intel
(Make sure the "-l" is included)

Mounting an ISO Image under Linux

To mount an ISO Image under Linux, you can do the following:

Step 1: Create the mount point
# mount -p /mnt/ISO

Step 2: Mount the iso file
# mount -o loop linux.iso /mnt/ISO

Step 3: List the file stored inside an ISO Disk
# cd /mnt/ISO
# ls -l

Finding information about a program or application

Using Command Line find
To find general information about a program or application, you can use file. For example, if you use
file /usr/bin/mplayer

You will get
/usr/bin/mplayer: ELF 32-bit LSB executable, 
Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs),
for GNU/Linux 2.6.18, stripped
This information tells us on the platform, whether dyanmics are used and for which kernel


Use the Command ldd
If you wish to retrieve all the dynamic linked libraries associated with the program vim, you can type
ldd /usr/bin/vim

You will get the libraries that vim requires
linux-gate.so.1 => (0x006cf000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00a61000)
libncurses.so.5 => /lib/libncurses.so.5 (0x06fdb000)
libacl.so.1 => /lib/libacl.so.1 (0x06a09000)
libgpm.so.2 => /usr/lib/libgpm.so.2 (0x00df8000)
libperl.so => /usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/libperl
..........
..........

Looking at Xorg High CPU Usage Issue for netbook

If you are suffering from excessive slowness from your netbook or your old and slow notebook, you may want to tweak the CPU frequency governor to performance mode instead of the general mode. How do you do that? If you are using Linux Mint, you have to install a utilities called cpufrequtils

Step 1: Install CPU Frequency Utilities
# apt-get install cpufrequtils

Step 2: Query the CPU frequency governors
# cpfreq-info

Step 3: Force the CPU to use performance mode
# cpufreq-set -g performance

If this does not resolve the issues, you really have to look at other possibilities that is impacting your Xorg. Sometimes it could be your video drivers not the CPU governor issues....

Thoughts on users-install software

Read an interesting FAQ writeup on user-installed software found on Linux Format Aug 09. I thought I summarise the article in my own words.

I think as most system administration will encounter this scenario quite frequently especially in a academic environment that users wants to install software of their own. How do we cope with this?

Suggestion 1: Building from Source
I think one of the easiest method is to simply allow users to install from source file. The users can unpack the source and configure, make and make install. For example:

$ ./configure --prefix=$HOME
$ make
$ make install

(which will install directories like bin, lib and share to the user's home directory)


Suggestion 2: If using RPM, you can use some prefix
$ rpm --prefix=/home/user/local --otheroptions
(and adding an entry to sudoers with sudo)

However, there are some issues as many packages are NOT relocatable and have to be installed to the path that was given when they are compiled.


Suggestion 3: Allowing restricted sudo access
If you allow users to install onto system directories, you can give them restricted rights like installing without removing.

BashGuide Wiki

BashGuide Wiki by Greg is an excellent material for beginner. According to the wiki which is still work-in-progress
This guide aims to become a starting point for people interested in learning to work with BASH. It aspires to teach its readers good practice techniques for developing scripts for the BASH interpreter, and to educate them about the internal operation of BASH......
To read it.

Using xrandr to change screen resolution and orientation

X RandR is a useful tool to configure display ports, display modes and properties such as orientation, reflection and DPI.

Some simple usage of xrandr
$ xrandr -v (Server reports RandR version 1.3)
$ xrandr -q (query what screens are connected)
$ xrandr -s 1280x800 (screen resolution)
$ xrandr -o inverted (orientation inverted, left, right, normal)

Do note that for xrandr -0 , your screen might freeze after the command, you may want to use xrandr --verbose to check the error.

To extend xrandr to utilise and join 2 monitor together, you may want to look at http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 for more information