Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
9Activity
0 of .
Results for:
No results containing your search query
P. 1
Linux Tips and Tricks

Linux Tips and Tricks

Ratings: (0)|Views: 546|Likes:
Published by kda73
Document offers Linux tips and tricks for the starting and more advanced user. These tips and tricks I have accumulated over the years which will make your life as a Linux sysadmin hopefully a bit easier. I hope that both experienced as well as novice Linux users will find these tips useful.
Document offers Linux tips and tricks for the starting and more advanced user. These tips and tricks I have accumulated over the years which will make your life as a Linux sysadmin hopefully a bit easier. I hope that both experienced as well as novice Linux users will find these tips useful.

More info:

Published by: kda73 on Sep 24, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/30/2012

pdf

text

original

 
Linux tips & tricks
Below you will find several tips and tricks I have accumulated over the years which will make your lifeas a Linux sysadmin hopefully a bit easier. I hope that both experienced as well as novice Linux userswill find these tips useful.Another great source for tips is here:http://www.squidoo.com/linux-tips-and-tricksHistory and the shellThe command “history” will show you the past commands you have used. It will also show you anumber in front of the command. If you type “!number” it will repeat the command from the past.If you type “!cd” it will append the last command which included cd. Example “cd /home/user”.Using “Alt and .”. If you press “Alt + .” it will cycle through the last part of the command. Another way of doing this is using the “!$” but then it will only use the last part and will not let you cyclethrough the commands you have already entered. Give it a try by doing a “ls /home/username” and theneither “cd !$” or “cd Alt+.”. If you type `cd -` you will go back to you last position. Ex. /home/me to cd/usr, cd – will let you go back to /home/me!If you use !* instead of !$ it will complete everything after say “vi bla bla2″, so everything after vi.Removing characters from a command. Say you have mistyped the command, ex rm blaa instead of rm bla. Press “^a” and it will come back with “rm bla”.If you go to directories of want to finish command you type press on the tab key to complete thecommand or location. Pressing it multiple times will let you cycle through the commands/directories.Reverse search – if you type “Ctrl + r” you can type in the first few keystrokes of a command to find itin your history.env – show user environment variables (in windows its “set”)sudo -i – opens a root shellsudo passwd -l root – disable root passwd (lock)sudo passwd -u root – unlock root passwd (if passwd was set before locking)sudo passwd root – enable root passwdsudo -s – opens a new shell and allows you to work like root without having to use sudo for eachcommand.cp source target – copy file from source to target ex. cp test /home/me (copy test to /home/me dir)mv source target – move or rename fileln -s target linkname – ex. ln -s /home/me/test test2 -> link to /home/me/test and call link link2.-s is symbolic link – removing the link doesn’t remove the original file – without -s is hardlink – removing the link will also remove the original file!! Be careful.ln -sd targetdir linkdirname -> make symbolic link to directorymd5sum -c MD5SUM (MD5SUM is file with checksum)Output redirection
 
ls > file – pipe output of command ls to filels >> file – append output to existing filels 2> file – only pipe errors to filels 2>&1 file – output stdout and stderror to file or “ls &> file” or ls > /dev/null 2>&1 – output stderr &stdout to bitbucket.mail kim < file -> mail command takes input from file and sends it to receiver wc < file > other_file -> wordcount takes input from file and pipes output to other_fileoutput can also be piped to screen for example a different console/terminal. try this “cal > /dev/pts/2″this will output a calender in the terminal no. 2. (ssh host “cal > /dev/pts/1″ – paste calender on remotemachine).reset – lets you clear the terminal (for ex. when its garbled).dd if=/dev/hda of=bla.iso – make an iso file from your dvd or cddd if=/dev/zero of=10MB bs=1024 count=10240 – make 10MB file.Signalskill -HUP pid – restart process with processid or kill -HUP `cat /var/run/process.pid`export GREP_OPTIONS=’–color=auto’ – shows match in red color ls /home/{user1,user2} – show content of both user1 and user2 homefir script filename – lets you record commands till you press Ctrl-D or type exit.mounting directories and serversIf you want to unmount a device which is currently in use you can find out about the processes whichare using this device by issuing a “lsof /mountpoint”. You can also issue the command lsof -n | grep“mountpoint” to achieve the same result. If a disk refuses to be umounted issue the command umount -l“mountpoint”.mount -o loop iso /mountpoint – mounts the iso at mountpoint (you can check its content)set noatime,nodiratime in fstab inclreases filesystem performance.vi /etc/fstab and add these two values after default option.mount -o remount / to remount filesystem.The atime,nodiratime keeps a record each time the file or dir was accessed – in most cases this is notnecessary.http://kerneltrap.org/node/14148Setting networkcard speedethtool -s eth0 speed 10|100|1000ethtool eth0 shows you the capabilities of the card.sudo netstat -plutn – open listening portshost domain (ex. host domain.com) – in newer host program shows MX records (Mail Exchanger records)update-alternatives –config editor – set default editor under ubuntu/debian systems.update-alternatives –config – change all your default settings. blkid – show all ids for disk partitions
 
Package managementMost Linux distributions use some sort of packagemanagement tools. Some systems use rpm (ex.RedHat/Fedora and SuSE) or deb’s (ex. Debian and Ubuntu etc.) or even source packages (ex. Gentoo).RPM based systemsrpm -qa – gives you a complete list of all the installed packages.rpm -Uvh packages – upgrades an package. The v part in the command means that the output should beverbose.DEB based systemsdpkg –get-selections give you a complete list with all installed (and uninstalled) packages.# dump packages to list and reinstall from listdpkg –get-selections > installed_packages.txtTo re-install the packages from the list# dpkg –set-selections < installed_packages.txt# apt-get dselect-upgradeapt-get install packagename – installs packagenameapt-get update – updates package databaseapt-get upgrade – upgrades all installed packagesapt-get clean – cleans deb’s which were downloadedapt-file search /usr/bin/vi – searches for file in package even if it uninstalleddpkg -S /usr/bin/file – searches for file in packages on local systemdpkg -l – list all packages installed/uninstalled on systemremoving packages when getting errors..dpkg –purge –force-all package_namedpkg –remove –force-all package_nameapt-cache search packagename – search for package in repositories.Cleaning up your debian based systeemI use both `deborphan` and `debfoster` to clean up the system of unwanted packages.Getting help!Man pages – if you type “man command” it will tell you more about the command and the possibleswitches. Or you can type either `–help`or `-h` behind the command to learn more about their operators.Related command’s in someway can be found by typing “apropos command”.GnomeSwitching workspaces – Crtl-Alt-Right/Left of you can use your scrollmouse by pointing the mouse pointer on the workspace switcher and scroll.Suddenly no sound after installing/deinstalling programs? I experienced this in Ubuntu – open thevolume control and crank up all the sliders.

Activity (9)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
ankit boxer liked this
Steve Lee liked this
Premchand liked this
ibbyAU liked this
siona123 liked this
inamaduguv liked this
scorp309 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->