Tuesday, November 27, 2012

Reload you /etc/inittab file

You made changes to your /etc/inittab file but can’t effort any downtime.
There’s a simple trick to reload and apply changes in your /etc/inittab file without a reboot.
Run “init q” or “init Q”
[root@snoopy ~]# init q
[root@snoopy ~]#
[root@snoopy ~]# init Q
[root@snoopy ~]#

Download with cURL

Here’s how to download a file using cURL.
curl -O [full url to file]
curl -O http://downloads.wordpress.org/plugin/simple-tags.1.6.6.zip
Sample Output;
[root@kmon01 bin]# curl -O http://downloads.wordpress.org/plugin/simple-tags.1.6.6.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 585k 0 585k 0 0 95317 0 --:--:

How to find the number of physical CPUs in Linux

With multicore CPUs it’s easy for newbies to get confused when faced with questions like;
1. How many physical CPUs does the server have?
2. How many cores on each CPU? Duo/Quad
In Linux it’s actually quite easy to get this info.
You could go through the /var/log/dmesg file or the /proc/cpuinfo file. For this tutorial we’ll look at the /proc/cpuinfo file.
Physical CPU count?
Run “cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l”.
[root@bender ~]# cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l
2
How many cores?
Runcat /proc/cpuinfo | grep “cpu cores” | uniq”.
[root@kmigb000 ~]# cat /proc/cpuinfo | grep “cpu cores” | uniq
cpu cores       : 2
2 mean that each physical CPU has 2 cores on it. If cpu cores was 1 then the CPU’s single core.
How many virtual processors?
Run “cat /proc/cpuinfo | grep “^processor”"
[root@bender ~]# cat /proc/cpuinfo | grep “^processor”
processor       : 0
processor       : 1
processor       : 2
processor       : 3
That’s about right, 2 physical CPUs x 2 cores each = 4 virtual processeors.
However, it’s a bit different for HT (Hyper-Threading). If you get cpu core = 1 but the virtual processors = 2 then the CPU’s running HT. HT will only work with the SMP kernel.

Good collection of Linux Tutorials

EduChoices published an excellent list of Linux tutorials. The list includes tutorials for Linux newbies and experts alike.
Check it out, a must have if you into Linux The list below was taken from EduChoices.

Linux and UNIX Training for Beginners

Free Linux Tutorials for Beginners

  • Introduction to Linux – This IBM tutorial is designed for people who want to learn what Linux is and how it can be used.
  • Linux Desktop 101 – This 14-week course teaches students how to run the Linux operating system on a PC.
  • Hands-On Introduction to Linux – Machtelt Garrels’ well-organized tutorial provides a hands-on introduction to Linux.
  • Real Time Linux Introduction – A series of introductory Linux tutorials from the National Institute of Standards and Technology.
  • Getting Started with Linux – This 20-lesson course from Linux Online is designed for people who are just getting started with Linux.
  • Linux Fundamentals Course – The Shuttleworth Foundation’s fundamentals course takes approximately 18 hours to complete and gives students a basic understanding of the Linux operating system.
  • The 35-Command Tutorial – This basic Linux tutorial from BeginLinux.org teaches 35 commands that every Linux user should know.
  • Getting Started with Linux Desktop – Novell’s self-study course teaches basic Linux desktop skills.

Free UNIX Tutorials for Beginners

  • UNIX Tutorial for Beginners – The University of Surrey’s beginner’s guide to the UNIX operating system features eight easy-to-follow tutorials.
  • A Basic UNIX Tutorial – This Idaho State University tutorial teaches the fundamental of UNIX computing. The tutorial includes examples and exercises.
  • UNIX Training Manual – This free 88-page training manual utilizes examples to teach UNIX filesystem commands. Not exactly a tutorial, but useful nevertheless.
  • UNIX Command Tutorial – University of Mississippi course that teaches students how to interact with a UNIX operating system and perform various commands.
  • Learn UNIX Tutorial – Soft Lookup’s comprehensive UNIX tutorial can take almost anyone from a beginner to an expert.
  • UNIX – The Bare Minimum – This tutorial, from a UC Davis professor, offers a basic introduction to UNIX.
  • Learning About UNIX – The University of Toronto offers open access to UNIX and Linux course notes. This course focuses on UNIX and Linux tools.
  • What is UNIX? – This tutorial offers a simple introduction to UNIX and offers access to a forum for UNIX beginners.

Linux and UNIX Training for Experts

Free Linux Tutorials for Experts

  • Linux Online’s Course for Advanced Users – This advanced course from Linux Online is fashioned into a series of how-to documents. Designed for people who want to learn more about installation, configuration and maintenance tasks.
  • Linux System Administration Course – This 28-module course provides comprehensive training for system administrators.
  • Kernel Tutorials – The kernel tutorials at HowToForge are a great way for Linux users to learn everything they need to know about kernels.
  • Advanced Routing and Traffic Control Tutorial – This advanced Linux tutorial teaches users about routing, filtering and traffic shaping.
  • Linux Enterprise Server Courses – Novell Training Services offers several different courses for advanced Linux users.
  • Linux Network Administration Course – The Shuttleworth Foundation’s Linux Network Administration Course is split into separate tutorials that teach the fundamentals of network administration.
  • Advanced Linux Programming – This tutorial is actually a book that can be downloaded for free. The book teaches users how to develop Linux software and write sophisticated programming.
  • IBM’s Technical Library – IBM’s Technical Library offers a number of useful tutorials for advanced Linux users.

Free UNIX Tutorials for Experts

  • UNIX for Advanced Users – Indiana University’s UNIX Workstation Support Group offers a great UNIX course for advanced users.
  • Kevin Heard’s UNIX Tutorial – Kevin Heard (UC Berkeley) has a fantastic three-part tutorial that starts with an overview of UNIX and ends with advanced topics.
  • Advanced UNIX Commands – Although this is more of a list than a tutorial, it makes a good reference for advanced UNIX users.
  • Parallel Programming Tutorial – This UNIX tutorial teaches advanced users the ins and outs of parallel programming.
  • Advanced Bash Scripting Guide – This UNIX tutorial from the Linux Document Project starts out with a programming overview and moves on to advanced scripting topics.
  • UNIX Shell Scripting Advanced – VTC has a number of UNIX tutorials that are in video form. This one guides advanced users through their first shell script.
  • Advanced C Shell Programming – This UC Davis tutorial teaches advanced C shell and tcsh programming techniques.

Sort files by size

Here’s how to sort files by size in Linux.
Standard;
ls -lhS
Reverse;
ls -lhSr
Options used;
-l –> print long listing
-h –> print human readable sizes
-S –> sort by file size
-r –> reverse order
Output;
[root@kmon01 log]# ls -lhS
total 70M
-rw-r--r-- 1 root root 36M Mar 31 11:28 messages
-rw-r--r-- 1 root root 15M Mar 31 11:25 cron
-rw-rw-r-- 1 root root 15M Mar 31 04:02 maillog
-rw-rw-r-- 1 root utmp 3.8M Mar 31 11:17 wtmp
-r-------- 1 root root 2.6M Mar 31 11:17 lastlog
-rw-r--r-- 1 root root 1.4M Mar 31 11:13 boot.log
-rw-r--r-- 1 root root 68K Mar 25 04:04 prelink.log
-rw-r--r-- 1 root root 67K May 25 2007 scrollkeeper.log
-rw-r--r-- 1 root root 54K Mar 31 04:02 rpmpkgs
-rw-r--r-- 1 root root 51K Dec 24 2007 xferlog
-rw-r--r-- 1 root root 38K May 25 2007 anaconda.syslog
-rw-r--r-- 1 root root 36K Jun 11 2007 Xorg.0.log
-rw-r--r-- 1 root root 15K Feb 2 10:34 dmesg
-rw-r--r-- 1 root root 13K May 25 2007 anaconda.log

[root@kmon01 log]# ls -lhrS
total 70M
-rw-r--r-- 1 root root 0 May 25 2007 spooler
-rw-r--r-- 1 root root 0 Mar 25 14:38 secure
-rwx------ 1 postgres postgres 0 May 25 2007 pgsql
-rw-r--r-- 1 root root 0 May 24 2007 mcelog
-rw-r--r-- 1 root root 23 Feb 2 10:35 snmpd.log
-rw-r--r-- 1 root root 715 Sep 1 2009 yum.log
-rw-r--r-- 1 mysql mysql 2.0K Dec 8 2008 mysqld.log
-rw-r--r-- 1 root root 2.1K Feb 2 10:35 acpid
-rw-r--r-- 1 root root 2.7K Mar 22 11:46 btmp
drwxr-xr-x 2 root root 4.0K Mar 31 11:21 httpd
drwxr-xr-x 2 root root 4.0K Mar 10 2006 gdm
drwxr-x--- 2 exim exim 4.0K Sep 9 2005 exim
-rw-r--r-- 1 root root 67K May 25 2007 scrollkeeper.log
-rw-r--r-- 1 root root 68K Mar 25 04:04 prelink.log
-rw-r--r-- 1 root root 1.4M Mar 31 11:13 boot.log
-r-------- 1 root root 2.6M Mar 31 11:17 lastlog
-rw-rw-r-- 1 root utmp 3.8M Mar 31 11:17 wtmp
-rw-rw-r-- 1 root root 15M Mar 31 04:02 maillog
-rw-r--r-- 1 root root 15M Mar 31 11:25 cron
-rw-r--r-- 1 root root 36M Mar 31 11:29 messages

How to Fix Ubuntu 10.10 VirtualBox Guest Additions Problems

If you’re trying to run Ubuntu 10.10 Beta on your VirtualBox, you’re most likely having issues with the screen resolution. Installing the default VirtualBox client doesn’t quite help. Try the steps below,
1. Open terminal and enter the following command:
#sudo apt-get update
#sudo apt-get install build-essential linux-headers-$(uname -r)
#sudo apt-get install virtualbox-ose-guest-x11

2. Once installation is finished, restart your VirtualBox machine.
3. Go to System –>Preferences –>Monitors and change the resolution of your screen. You might be able to change the resolution but the screen will re-size properly when you maximize.

How to reset your Gnome desktop

So you messed up the Gnome desktop and don’t know how to restore it back to it’s default settings. Here’s how with no risks.
1. Log out and then hit “Ctrl + ALT + F1″ to opening up a terminal.
2. Delete the following directories.
.gnome .gnome2 .gconf .gconfd .metacity
Or run the this command.
rm -rf rm -rf .gnome .gnome2 .gconf .gconfd .metacity
3. “Ctrl + ALT + F7/F8″ and log in as usual.
This guide is based on Ubuntu 10.10