Handy commands will always help you to do your daily tasks on a LINUX system or server. You just need to remember and use them on time and you will perfectly get best results. Few Commands are given as under which can save your lot of time.
1. pgrep
pgrep will give you the currently running processes and lists the process IDs which matches the selection criteria.
pgrep ssh
2. Execute The Last Executed Command
If you like to reissue a command again you need to type the whole path and command again to get the results, you can just enter the under given command;
!!
3. Execute The Last Command Starting With some letter
If you want to execute a command a command from history starting with the letter S you can use the following command: This will execute the last command used on the command line that started with s.
!s
4. Run a Command Repeatedly and Display the Output
It will run a command repeatedly, displaying its output. This allows you to watch the program output change over time. By default, the program is running every 2 seconds.
watch -d ls -l
The above given command will watch the current directory for any file changes and highlight the change when it occurs.
5. Save Quickly in VI/VIM
I like to use vi editor for all kinds of modifications and changing in any file in LINUX or UNIX system because it offers very handy and great features. I would like to share one very good feature of vi editor over here. If you like to close the vi editor at once and also want to save the data use the under given command;
exit insert mode by pressing escape, hold shift, and hit z twice.
This can be very handy and time saving if you have to create a number directories with almost same name but have different numbers. You can use this command to Save time when making multiple files or directories (or performing any command requiring a list) where the file names only slightly differ. Commands are given as under;
$ ls
$ touch ito{1,2,3,4,5}.txt
$ ls
ito.txt ito.txt ito.txt ito.txt ito.txt
$ mkdir dir{1,2,3}
$ ls
dir1 dir2 dir3 ito.txt ito.txt ito.txt ito.txt ito.txt
If you are familiar using SSH to connect to any of your LINUX/UNIX machine then you probably have an idea of authentication key use in SSH. You can create your own authentication key to solve a couple of problem like logging in directly without entering any password and many more. How to create an authentication key in SSH?
The first step is to use "ssh-keygen" to create an authentication key for yourself. In most cases, the defaults are what you want. If your site has specific policies or procedures for key generation and management you should give these priority over any of the following guidelines.
Always choose a good passphrase. It can be multiple words (i.e. spaces are allowed within the phrase), so a sentence that you can remember is a good choice. Intentionally misspelling some of the words or substituting digits for letters is highly recommended to increase the strength of your passphrase.
Here is a sample session. Note that the passphrase is not echoed back as you type it.
[ITOPERATIONZ:/home/itm]
$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/itm/.ssh/id_dsa):
Created directory '/home/itm/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/itm/.ssh/id_dsa.
Your public key has been saved in /home/itm/.ssh/id_dsa.pub.
The key fingerprint is:
1a:3b:52:2e:63:1c:e3:d0:03:87:1a:ce:74:00:a2:62 itm@ITOPERATIONZ
Environment |
|
| env | Show all environment variables. |
| export | Set the value of a variable so it is visible to all subprocesses that belong to the current shell. |
| printenv | Print all or part of environment. |
| reset | Restores runtime parameters for session to default values. |
| set | Shows how the environment is set up. This is a builtin bash command. |
Library management |
|
| ldconfig | Updates the necessary links for the run time link bindings. |
| ldd | Tells what libraries a given program needs to run. |
| ltrace | A library call tracer. |
| trace | Same as ltrace. |
Module and kernel management |
|
| depmod | Handle loadable modules automatically. Creates a makefile-like dependency file. |
| dmesg | Print or control the kernel ring buffer. This shows the last kernel startup messages. |
| genksyms | Generate symbol version information. |
| insmod | Install loadable kernel module. |
| lsmod | List currently installed kernel modules. |
| modprobe | Used to load a set of modules that are marked with a specified tag. |
| rmmod | Unload loadable modules. |
If you are LINUX lover and like to learn more and more than I am pretty sure that you will like this post because its gonna give you a long list of LINUX tutorials and other things, Like screen shots, basic commands, LINUX things for beginners and many many more.
Beginners Guide/Howto’s/Tips/Software/Man Pages/WebDesign
Linux Basics
Linux Links for Beginners
Ultimate Linux Newbie Guide
Linux Knowledge Base and Tutorial
nixCraft Tips & Tricks Newsletters
nixCraft Tutorials
Great Linux Tutorials
General Linux Tutorials
Linux Online – Linux Courses
Wanna Learn Linux?
LinuxPlanet Tutorials
Linux Users Guide
Linux File Managers
Intro to Linux
The Beginner’s Linux Guide
Quick-N-Dirty Guides (incl Samba)
From DOS/Windows to Linux HOWTO
Linux-Firewall.org is a full-featured, easy to use, application based personal firewall for Linux. This software will give you the opportunity to decide which programs are allowed to connect to a network/the internet and will not just block IP addresses like many others do. Studies have shown that Linux is becoming more and more interesting for criminals because the number of users grows every day. So Linux-Firewall.org is the best choice to protect yourself against Trojans, viruses, root kits and non-open-source software trying to connect to the internet without your permission.
Basic Linux commands can give you more appropriate and better result in terms of system monitoring than other very professional tools created by third parties. You just need to remember the command and its appropriate flag to use for desired results.
|
pstree |
Processes and parent-child relationships |
|
top |
Show top processes |
|
iostat |
Report CPU statistics and input/output statistics for devices and partitions. |
|
ps -auxw |
process status |
|
uname -a |
print system information |
|
cat /proc/version |
Display Linux kernel version in use. |
|
cat /etc/redhat-release |
Display Red Hat Linux Release. (also /etc/issue) |
|
uptime |
Tell how long the system has been running. Also number of users and system’s load average. |
|
w |
Show who is logged on and what they are doing. |
|
/sbin/lsmod |
List all currently loaded kernel modules. |
|
/sbin/runlevel |
Displays the system’s current runlevel. |
|
hostname |
Displays/changes the system’s node name. (Must also manually change hostname setting in /etc/sysconfig/network. Command will change entry in /etc/hosts) |
|
service |
Red Hat/Fedora command to display status of system services. |
There are more than a one methods available to create directories and sub directories in LINUX and UNIX. One method can be a hard work (Laborious work) but the other might be a very easy and efficient way. I am going to share both ways to give a better idea about directory creation.
Hard Work Example: Defining directory trees individually
~ $ mkdir tmp ~ $ cd tmp ~/tmp $ mkdir a ~/tmp $ cd a ~/tmp/a $ mkdir b ~/tmp/a $ cd b ~/tmp/a/b/ $ mkdir c ~/tmp/a/b/ $ cd c ~/tmp/a/b/c $
It is so much quicker to use the -p option to mkdir and make all parent directories along with their children in a single command. But even administrators who know about this option are still caught stepping through the subdirectories as they make them on the command line. It is worth your time to conscientiously pick up the smart method:
Smart Work Example: Defining directory trees with one command
~ $ mkdir -p tmp/a/b/c
You can use this option to make entire complex directory trees, which are great to use inside scripts; not just simple hierarchies. For example:
Smart Work Example: Defining directory trees with one command
~ $ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
In the past, the only excuse to define directories individually was that your mkdir implementation did not support this option, but this is no longer true on most systems.
For the few systems that still lack the capability, use the mkdirhier script which is a wrapper for mkdir that does the same function:
~ $ mkdirhier project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
LINUX and UNIX command line can create and burn an ISO image more easily than a graphical environment. There are hundreds of hundreds tools available in LINUX, UNIX and Windows to do this task but most of tools are not freely available. We have a lots of commands available in LINUX and UNIX environment to do this task.
Use mkisofs to create a CD/DVD image from files in a directory. To overcome the file names restrictions:
-r enables the Rock Ridge extensions common to UNIX systems
-J enables Joliet extensions used by Microsoft systems.
-L allows ISO9660 filenames to begin with a period.
mkisofs -J -L -r -V TITLE -o imagefile.iso /path/to/dir
cdrecord dev=ATAPI -scanbus
burncd -f /dev/acd0 data imagefile.iso fixate # For ATAPI drive
cdrecord -scanbus # To find the burner device (like 1,0,0)
cdrecord dev=1,0,0 imagefile.iso
-dvd-compat closes the disk
growisofs -dvd-compat -Z /dev/dvd=imagefile.iso # Burn existing iso image
growisofs -dvd-compat -Z /dev/dvd -J -R /p/to/data # Burn directly
Mounting an image in LINUX and UNIX is very easy but if you slip something, you will end up with a couple of bad tries and then you will give up or try to find it on the internet. Let me share two very easy commands that can help you to mount an ISO image on LINUX and UNIX.
Mount an ISO image on Linux loop-back;
mount -t iso9660 -o loop file.iso /mnt # Mount a CD image
Mount an ISO image on Linux ext3
mount -t ext3 -o loop file.img /mnt # Mount an image with ext3 fs
Mount an ISO Image on FreeBSD With memory device (do # kldload md.ko if necessary):
mdconfig -a -t vnode -f file.iso -u 0
mount -t cd9660 /dev/md0 /mnt
umount /mnt; mdconfig -d -u 0 # Cleanup the md device