Archive for the 'shell' Category
Posted by: admin (Oct 19) Ctrl + A Go to the top of the line you are typing.
Ctrl + E Go to the end of the line you are typing.
Ctrl + L Clear the screen.
Ctrl + U Clears the screen before the cursor. If you are at the end of the line, clears the entire line.
Ctrl + R allows you to search through previously used commands.
Ctrl + C Stop whatever you are doing.
Ctrl + D Exit the current shell.
Ctrl + Z starts the suspension in the background whatever you are doing.
Ctrl + W Delete the word before the cursor is.
Ctrl + K Clear the line after the cursor.
Ctrl + T Reverses the last two characters before the cursor.
Esc + T Swap the last two words before the cursor.
Alt + F Move cursor forward one word in the current row.
Alt + B Move cursor back one word in the current row.
Tab Auto-Complete the names of files and folders.
Paste Ctrl + Y (as in copy and paste) all the text before the cursor.
Note: Some of these commands do not work if shell access is via telnet, or SSH session if the keyboard is a particular configuratain
Published in: linux , shell , tips Posted by: admin (Apr 20) When we install spamassassin on our mail server we have installed a script used to download the rules to improve the capture of email spam coming to our server.
The script is called sa-update . Below we report a simple crontab entry to be included in your linux box to call every day at 7:00 and the script to keep up to date with the rules of your spamassassin.
0 7 *** / usr / bin / sa-update-D-updatedir / etc / mail / spamassassin /
Remember to also restart the spamassassin service after the update with the command:
/ Etc / init.d / spamassassin restart
or
/ Etc / init.d / spamd restart
NOTE: Commands and locations can vary from distro to distro, but for the sysadmin should not be difficult to find the correct position. In case of difficulty please contact us or leave a comment.
Published in: linux , shell , spam , tips Posted by: admin (Tue 15) As for the outdated windows even in Linux distributions, in our case we take Ubuntu for example you can add fonts (fonts) so easy.
from a terminal just type the command:
sudo nautilus / usr / share / fonts / truetype /
Remember that for every distribution you should replace your Nautilus file manager like dolphin for kubuntu. After copying the true type fonts in this location, you can also put the sub directories to better organize your fonts you have to start the refresh cache fonts with the command:
fc-cache-f-v
You're done, simply open the application you want to use the fonts of interest to us.
Published in: linux , shell , tips , ubuntu Posted by: admin (Jan 17) Often you have to put hand to full-bodied configuration files where we can make do with a handful of parameters. In these cases we can remove all the unnecessary fluff simply using the command shown below:
# Grep-v "^ #" / etc / my.conf | sed-e '/ ^ $ / d'> / etc / my_new.conf
or you can use this alternative:
# Cat / etc / my.conf | sed '/ * # / d / ^ * $ / d'> / etc / my_new.conf
Remember to my_new.conf to overwrite the original file after checking the contents.
Published in: linux , shell , tips Posted by: admin (set 12) Show all rpm packages installed:
# Rpm-qa
Query the db rpm filtering out all packets containing the string 'httpd':
# Rpm-qa | grep httpd
Obtaining information about a specific package installed, eg:
# Rpm-qi httpd
Display the list of files provided by a package installed, eg:
# Rpm-ql httpd
Display only the list of configuration files provided by a package installed:
# Rpm-qc httpd
Get information on the documentation provided by a package:
# Rpm-qc httpd
Display the list of dependencies required for a package:
# Rpm-q httpd-whatrequires
Show capability provided by a package:
# Rpm-q httpd-whatprovides
Show scripts started during installation / removal:
# Rpm-q httpd-scripts
Show history of revisions of the package:
# Rpm-q httpd-changelog
Check out which package owns a given file:
# Rpm-qf / etc / httpd / conf / httpd.conf
Display the list of files provided by a package not yet installed:
# Rpm-qp-2.0.52-3.i386.rpm httpd-l
Fedora / RedHat, sign all packets with a digital private GPG key. To import the public-key using the following command:
# Rpm-import / media / cdrom / RPM-GPG-KEY
To verify the integrity of a package before proceeding with the installation, especially if it is downloaded from the Internet, run the next command:
# Rpm-checksig package_name.rpm
To verify all packages installed on your system:
# Rpm-qa gpg-pubkey
Install a binary package:
# Rpm-ivh package_name.rpm
Install a binary package ignoring dependencies requests:
# Rpm-ivh-nodeeps package_name.rpm
Install a binary package by sending the automatic resolution of dependencies:
# Rpm-ivh-aid package_name.rpm
Upgrading a package without changing configuration files:
# Rpm-U package_name.rpm
Updating a package only if it is already installed:
# Rpm-F package_name.rpm
Rimuore a rpm package:
# Rpm-e package_name
Check file size, permissions, type, owner, group, MD5 checksum and last modification on the RPM database:
# Rpm-V httpd
Check all packages installed on your system - use with caution, the system engages in an extreme way:
# Rpm-Va
Verifying a package not installed:
# Rpm-Vp httpd-2.0.52-3.i386.rpm
This command allows you to extract files from the package to be converted into a stream and then cpio to extract the executable from the package:
# Httpd-2.0.52-3.i386.rpm rpm2cpio | cpio-extract-make-directories * bin *
Installing a source package i386.
Step 1:
# Rpmbuild-rebuild nome_pacchetto.src.rpm
Step 2:
# Rpm-ivh / usr/src/redhat/RPMS/i386/nome_pacchetto.rpm
Installing a source package i386 (alternative procedure).
Step 1:
# Rpmbuild-recompile nome_pacchetto.src.rpm
Step 2:
# Rpmbuild-bb / usr / src / redhat / SPECS / nome_pacchetto.spec
Step 3:
# Rpm-ivh / usr/src/redhat/RPMS/i386/nome_pacchetto.rpm
Creating a rpm package from source.
We want to create a package from source application example. We download the source from the internet with wget:
# Wget http://www.example.org/dl/example-2.0.0.tar.gz
# Cp example-2.0.0.tar.gz / usr / src / redhat / SOURCE
# Cd / usr / src / redhat / SOURCE
# Example-2.0.0.tar.gz tar xzf
Check if directory exists within the unzipped file. 'Spec', which contains the specifications for the creation of the track, and copy it to / usr / src / redhat / SPEC:
Example.spec # cp / usr / src / redhat / SPEC / example.spec
If the file. Spec does not exist can be created. Finally, prepare the filling for the creation of the new rpm:
# Cd / usr / src / redhat
# Rpmbuild-bb SPECS / snort.spec
Published in: linux , redhat , shell , tips Posted by: admin (set of 4) Linux systems usually have a preset limit of 1024 files open simultaneously. This limit is indeed quite low in case of machine with high workloads, particularly in the presence of web servers with many different domains and pointers to files and logs.
When you reach the production stage, and you exceed this limit are often strange inconsistency problems. So you better act quickly. Knowing the process-id of our application (eg tomcat or httpd) with the command seguende we examine the number of files that the process is holding open:
lsof-p [process-id] | wc-l
After understanding the problem we can intervene minimally with ulimit. Use the following commands to get information about system settings:
ulimit-Ha
ulimit-Hs
Finally, to revise the maximum simultaneously open files in Linux we can type:
ulimit-n 4000
See also the manpages for more info on the command and all of its options:
man ulimit
Published in: linux , shell , tips Posted by: admin (Jun 23) If you want to force the file system check to restart our linux box can simply create at the root "/" file forcefsck:
# Cd /
# Touch / forcefsck
# Reboot
Published in: linux , shell , tips Posted by: admin (Dec 17) For those who come from long experience from RHEL 4.X has certainly had to deal with the command ext2online. This brief note to remember that in RHEL 5.X there is no longer this command. To resize the partition is mounted simply use the command resize2fs. The control automatically detects the status of the partition and behaves accordingly. Below is an example:
[Root @ host ~] # resize2fs / dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at / dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of / dev/mapper/VolGroup00-LogVol00 to 4923392 (4k) blocks.
The filesystem on / dev/mapper/VolGroup00-LogVol00 is now 4923392 blocks long.
Howto Forge on a howto on how to resize the partition EXT2 / 3 without losing data .
Published in: linux , shell , tips Posted by: admin (Dec 16) EXT2 and EXT3 partitions have the default 5% of the space reserved for the 'root. This is a good thing to avoid that the system runs out of space in the presence of users salami intent to clog the filesystem with amenities. But if the partition in question does not need all this space, as in the case of a removable disk or partition storing / backup then we can intervene and remove this limit:
# Tune2fs-m 0 / dev/sdc5
The example set to zero in the space reserved on the ROOT partition sdc5, sdc5 replaced with the partition, and immediately you have recovered your precious space. (Do not forget to do the task as root, unprivileged users can not intervene).
Published in: linux , shell , tips Posted by: admin (Oct 25) When we use the ls command can display the permissions of files in the following format:
-Rw-r-r-1 user group 49296 March 24 2006 file.bin
As they need to display octal permissions on the files themselves recommend this script:
ls-l | awk '{k = 0; for (i = 0; i <= 8; i + +) k + = ((substr ($ 1, i +2.1) ~ / [rwx] /) * 2 ^ (8 -i)) if (k) printf ("% 0th", k) print} '
The command displays + style octal permissions drwxr-xr-x.
If you are satisfied with the result you can make more permanent and easier to use in creating an alias in your shell you used to parameterize and pleasure. For bash you have to edit the file in your home directory ~ /. Bashrc, after logout and login you can use the command 's' to the classic alternately comanto 'ls':
alias l = 'ls-lha-color | awk' {k = 0; for (i = 0; i <= 8; i + +) k + = ((substr ($ 1, i +2.1) ~ / [rwx] / ) * 2 ^ (8-i)) if (k) printf ("% 0th", k); print} '"
Result:
600-134K rw --- 1 user group 21 April 2006 mbox
Published in: linux , shell , tips
Posted by: admin (Oct 22) For those who use the power of Linux shell will certainly not be escaped using ssh, the power of the tool will stop only when we need to scollegarci running while letting a process launched from our session. The system is ruthless, if I get disconnected all the processes we are killed immediately triggered. To overcome this there is the command screen ready to come to our aid by adding an additional efficiency to the remote shell of our Linux boxes. Screen is a "multiplier terminals" that allows us to handle multiple terminals, "decoupling" from the session process, and "hang up".

- screen starts screen and gives us our shell: we can work as if nothing had happened.
- screen + ProgramName start the program ProgramName inside screen, as with the shell.
- by pressing ctrl + a and then c inside a screen session we will create a new terminal.
- by pressing ctrl + a and then n pass next to the terminal.
- and then press ctrl + p to pass to the previous terminal.
- by pressing ctrl + a and then d "disengage" from our current session screen, while running the commands pending. Now we can finish our ssh session with the assurance that our processes are not collided.
- screen-r retrieves a session previously "dropped".
Example (Updating a remote system via yum):
First connection:
- ssh host.domain
- screen yum-y update
- Ctrl + a
- d
- exit
According to Link:
- ssh host.domain
- screen-r
- If there will still be running yum coast is doing. If yum has finished his task then you'll see the message [screen is terminating]
- exit
Published in: linux , shell , tips Posted by: admin (Oct 15) To get a personalized welcome message after login via ssh simply edit the file / etc / motd.
Optionally you can edit the file / etc / profile to display the date, uptime and other info.
Another option is to create a banner for the sshd daemon, the banner will be displayed before login. Enter 'Banner / etc / banner' in sshd_config
Published in: linux , shell , tips