Linux tutorials and more...
How do I automatically start an application after KDE start up?
Question:
I'm using KDE4. How do I automatically start an application after KDE start up?
Answer:
To automatically start an application after KDE start up navigate to:
KDE->Computer->System Settings->System Administration Section->Startup and Shutdown
In this window click on "Add program" button. Select your desired application from a menu or enter a full path to an executable binary. This will instruct KDE to start an application after it finished its boot.

Read more: How do I automatically start an application after KDE start up?
In what directory will the command cd .. not do anything at all?
Question:
In what directory will the command 'cd ..' (note the two dots in this command) not do anything at all?
Answer:
In root directory "/".
Since the .. directory points to a parent directory and / ( root directory ) is on the top of the file system hierarchy standard and therefore it does not have a parent directory, the "cd .." command will not do anything at all. We may also say that / directory is a parent directory of itself. Try:
$ cd / $ pwd / $ cd .. $ pwd /
Long Answer:
Every directory in the linux file system contains two special directories and they are:
- "." a current working directory
- ".." a parent directory
To see these special directories enter command:
ls -a
Current working directory "." points to itself.
Examples:
The command below will copy a file from /tmp directory to a current working directory:
cp /tmp/file .
Ore check disk space mounted below my current working directory:
df -h .
Parent directory ".." points to a directory one above my current working directory.
Examples:
Use a symbolic path to navigate to different directory in the same parent directory:
$ pwd /tmp $ cd ../etc/ $ pwd /etc
Navigate two directories above my current directory:
$ pwd /etc/terminfo $ cd ../.. $ pwd /Add a comment
Read more: In what directory will the command cd .. not do anything at all?
Check domain name availability with bash and whois
The following bash script allows user to check for domain name availability using a whois utility ( Domain hijacking made easy ). User needs to only supply single or multiple keywords and the script checks domain availability for each keyword+domain-label. See below for a sample output.
Please feel free to add more generic domain labels into the list. However, test your whois server on what it returns if domain is available as not all whois servers return the exact string. I have tested only domains which are currently in the bash script below. When you get a string which your whois server returns when domain name is available, add it to the script's grep line starting with prefix"|". The chances are that if you add new domain name label the script will just work, but if not you know what to do.
Insert following lines into a file called check-domain-availability.sh
Read more: Check domain name availability with bash and whois
Server hardening by eliminating setuid and setgid binaries
It is very possible that your Linux server has more packages installed than your really need. To make it worse, those extra packages may contain handful of binaries with setuid and setguid turned on. This can lead to unnecessary risk as it could be just a matter of time that some of your shell users exploits this vulnerabilities to get a root privileges.
The following command creates a list of all executables on your system with setuid and setgid.
find / * -perm +6000 -type f -exec ls -ld {} \; > setugid.txt
Review setugid.txt list carefully and remove "s" bits from binary with:
# chmod a-s /path/to/binary/file
Â
Add a commentRead more: Server hardening by eliminating setuid and setgid binaries
Hotfile direct download with wget
If you wish to download files from a hotfile.com ( file hosting ) using wget you need to have three things:
- hotfile premium account
- hotfile direct downloads enabled in you hotfile profile
- OS with a wget command
Once you have all of the above, create a following script and insert your hotfile authentication credentials:
#!/bin/bash MYUSERNAME=<your hotfile username here> MYPASS=<your password here> wget -q --save-cookies .hotfile-cookie --post-data \ "returnto=%2F&user=$MYUSERNAME&pass=$MYPASS&=Login"\
-O - http://www.hotfile.com/login.php > /dev/null for i in $( cat $1); do wget -c --load-cookies .hotfile-cookie $i done rm .hotfile-cookie
The above script accepts a single argument and that is a file with all URLs you wish to download. One URL per line ! Make the script executable:
$ chmod +x hotfile-direct-download.sh
Execute the script and supply a single argument with all URLs to download:
$ ./hotfile-direct-download.sh URLs.txtAdd a comment
What access modes (permissions) are given to new created files?
Question:
What access modes (permissions) are given to new files you create?
Answer:
The easiest way to find out what permissions are given to new files you create is to create a file and check its permissions using ls -l command:
$ touch new-file $ ls -l new-file
However, permissions given to a new created file may vary from system to system. The key variable to set permissions to a newly created files and directories is umask. You can check settings of your umask value by executing umask command without any arguments and options.
umask
On most of Linux / Unix systems the command above will return 0002 . To calculate permissions of a new created file in an accordance with umask value 0002 we subtract this value from 666 in a following manner:
666 002 --- 664 = rw-rw-r--
Read on for more reliable umask calculation method.
Long answer:
What all of this means?
Firstly, 666 and 002 are octal representations of a file / directory permissions. Permissions rw-rw-r-- are read like:
- rw- = read and write permissions for on owner
- rw- = read and write permissions for a group
- r-- = read only permissions for everyone else
where
- r ( read ) = 4
- w ( write ) = 2
- x ( execute) = 1
- and - ( no permissions ) = 0
Therefore, if we for example want to give an owner of the file read and execute permissions, we add 4 + 1 which gives us 5 ( r-x ). Furthermore, the octal representation of no permissions for a group and others will be 00. Put it together and we get 500. Make sure you understand all of the above before continuing !
Now we can go back again to our previous umask calculation:
666 002 664 = rw-rw-r--
This umask calculation will only work for some common umask values such us: 0000, 0007, 0027 . However, calculating umask value of 0014 using the same method as example above will give us:
666 014 652 = rw-r-x-w
but files created with umask 0014 have a default permissions of -rw-rw—w- . What is wrong?
The best and the most reliable method for calculation umask permissions is by use of bitwise NOT and bitwise AND operators. If you need to refresh your memory on what bitwise AND and OR operators are here are couple examples:
- NOT(0) = 1
- NOT(1) = 0
- NOT(110) = 001
- 1 AND 0 = 0
- 1 AND 1 = 1
- 001 AND 111 = 001
Now that we all know how to calculate bitwise AND and NOT we can calculate umask 0014. For all files we start with an octal base value 6-6-6 and umask 0-1-4 converted to binary.
- 666 = 110 110 110
- 014 = 000 001 100
At this point we can perform NOT operation for binary umask value:
NOT( 000 001 100 ) = 111 110 011
And as a last step we calculate AND operation of base and umask binary values:
110 110 110 AND 111 110 011 ----------- 110 110 010 = 662 = rw-rw--w-
Note that calculating umask permissions for directories is same as calculating umask permissions for files except that we change base value from 666 to 777. Here is an example of calculating umask permissions for a directory where umask value is 0241:
Again we start with conversion of base and umask values to binary:
- 777 = 111 111 111
- 241 = 010 100 001
Now we rerform NOT operation on umask:
NOT( 010 100 001 ) = 101 011 110
and as a last step we do AND operation of base and umask value:
111 111 111 AND 101 011 110 ---------- 101 011 110 = 536 = r-x-wxrw-
or simply:
777 241 --- 536Add a comment
Read more: What access modes (permissions) are given to new created files?
What command prevents other users from sending you messages?
Question:
What command prevents other users from sending you messages? How do you reset the variable to allow messages once again?
Answer:
To stop other to send you a local message using your terminal use mesg command. The syntax is simple as :
mesg y
to allow others to access your terminal thus writing you a message where
mesg n
does the exact opposite.
You can view your current mesg settings by executing the mesg command without any arguments and options:
dmesgAdd a comment
Read more: What command prevents other users from sending you messages?
Why is the GNU/Linux filesystem referred to as hierarchical
Question:
Why is the GNU/Linux filesystem referred to as hierarchical?
Answer:
GNU/LINUX system does not have so-called drives with assigned letters as it can be seen in MS Windows environment. Instead hard drive can by mounted ( connected ) to any directory within an entire file system. On the top of the file system hierarchy structure is a root directory represented by "/" which expands to sub-directories forming hierarchical tree.
Further reading:
Add a commentRead more: Why is the GNU/Linux filesystem referred to as hierarchical
Joining MP3 music files to a single track
Joining MP3 files can be rather simple task with a cat command. Suppose we have a directory with multiple MP3 files. The following cat command will join all MP3 files in a current directory to a single file called out.mp3:
$ cat *.mp3 > out.mp3
If we wish to join only specific files we can name them on a command line separately:
$ cat file1.mp3 file2.mp3 > out.mp3
NOTE: You will lose all tags such as artist, album which are related to each track.
This approach is good if all of your MP3 files are from the same album which means that there is a good change that they all have same volume settings. If we wish to join MP3 files with different volume setting we first need to perform normalization first, so there will be no sudden volume spikes between tracks:
$ normalize-mp3 *.mp3
In case you do not have normalize-mp3 command available but you only have normalize or normalize-audio command you need to first convert all MP3 files to a wav format:
$ for i in $( ls *.mp3); do ffmpeg -i $i $i.wav; done
Next normalize all volume settings for each wav file:
$ normalize-audio *.wav
Now we either convert all files to MP3 and join them with cat command or we can use sox command to join all wav files to a single file and then convert it to MP3 format:
$ sox file1.wav file2.wav file3.wav out.wav
And now convert the out.wav file to mp3 with ffmpeg:
$ ffmpeg -i out.wav -acodec libmp3lame out.mp3Add a comment
Install Java SE Runtime Environment on Fedora Linux
By default your Fedora Linux system comes with a OpenJDK Java fetched from a standard Fedora repository. You may have some reasons to switch from OpenJDK to Oracle Java JRE. In order to achieve this firs download a java binary form oracle website:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
as a root user make jre binary executable:
# chmod +x jre-6u23-linux-i586.bin
and execute the binary with:
# ./jre-6u23-linux-i586.bin
Switch over from OpenJDK to Oracle JRE: The above command extracted all content of jre-6u23-linux-i586.bin into a directory jre1.6.0_23. Move this directory to /opt/
# mv jre1.6.0_23/ /opt/
use alternative command to make oracle java JRE a default java environment:
alternatives --install /usr/bin/java java /opt/jre1.6.0_23/bin/java 20000Add a comment
Android Eclipse Keyboard Shortcuts
It is highly recommended to use the Eclipse IDE as an Android application development environment. Eclipse IDE nicely integrates a Android SDK into Eclipse by the use of Android Development tools. In case that you have decided to use Eclipse IDE here are some shortcut to make your android application development much faster:
| Action | Keyboard Shortcut |
| Create a new file in the current package | Alt+Shift+N |
| Organize the import statements | Ctrl+Shift+O |
| Navigate to the source definition | F3 |
| Rename an object | Alt+Shift+R |
| Search through Java files | Ctrl+H |
| Open a particular type | Ctrl+Shift+T |
| Find declarations | Ctrl+G |
| Navigate left | Alt+left-pointing arrow |
| Navigate right | Alt+left-pointing arrow |
Â
Add a commentBasic Linux Kernel module administration commands
| Basic Linux kernel module administration commands | |
|---|---|
| Basic Linux kernel module administration commands | |
| Linux command syntax | Linux command description |
| ls -R /lib/modules/$(uname -r) | Command to list all modules available for a given linux system |
| modinfo /path/to/module.ko | Display module information |
| insmod kernel-module-name | Install a module to a running kernel. NOTE: this command does not resolve module dependencies |
| modprobe kernel-module-name | Install a module to a running kernel inlcuding dependencies |
| depmod -a | Rebuild module dependancy database using /lib/modules/$(uname -r)/modules.dep |
| insmod --force kernel-module-name | Force insmod to load module even if its build for a defferent module version |
| modprobe -n -v kernel-module-name | Display insmod commands to load module and its dependencies. Useful when modprobe gives up due to dependency problem |
| lsmod | Display all modules currently loaded into a kernel |
| rmmod kernel-module-name | Command to remove a module from a running kernel |
This kernel requires the following features not present: pae
Today I have tried to install RHEL6 i386 as a virtual machine using virtualbox. Right after startup I got a error message saying:
This kernel requires the following features not present: pae Unable to boot - please use a kernel appropriate for your CPU
If you get this error enable PAE/NX on your virtual machine by navigating to:
Settings->System->Processor->Extended Features and tick: PAE/NX
Add a commentunrar - rar extract on fedora linux
Rar archive utility is not avaiable on Fedora linux by default. If you are i need to extract / unrar rar archive files you can use official rarlab command line tool.
First download rar utility package for linux from rarlab.com/download.htm .
Extract gzip tarball:
tar xvzf rarlinux-4.0.b6.tar.gz
move rar directory into /opt/
# mv rar /opt/
Next, we need to include rar and unrar executables into our shell path so we do not have to enter full path every time we want to execute it. Use your favorite text editor and add / alter a following line into your ~/.bash_profile:
PATH=$PATH:$HOME/bin:/opt/rar/
Now you need to logout and login again and you should be able to extract any rar archive file with unrar executable:
$ unrar x rar-file.rarAdd a comment
A Practical Guide to Linux Commands
This article lists various practical Linux commands to be used only as a reference guide and by experienced Linux users. Not all Linux commands will be available on your system by default so consider install a relevant package before use. This Practical Guide to Linux Commands may list Linux commands you already know but cannot remember usage syntax as well as it may introduce some new Linux commands to improve your Linux command line efficiency. Note, this guide will not teach you how to use Linux commands since it relies on your experience to alter Linux commands syntax below to fit your needs.
Add a commentAndroid system architecture
Linux Kernel
Linux kernel provides an abstraction hardware layer for an Android. This allows an Android to be ported into variety of different devices. Furthermore the linux kernel is used for android's  memory management, process management, netwoking and other underlined operating systems services.
Native Libraries
These shared libraries are pre-installed on a android device by each vendor. They are written in C/C++ language and allow 3D and 2D graphics, window manager, all sorts audio video formats, Sqllite database and etc.
Android Runtime
This layer includes Dalvik Virtual machine code and core Java Libraries.
Application Framework
Android Application framework is a high-level layer to provide a developer with a space for a new Android applications development.
Applications and Widgets
This is the highest level of the Android system architecture. End user android applications and widgets layer.
Android system architecture

Page 5 of 9













