Linux related stuff goes here :)
Table of Contents
|
General Links
- http://en.wikipedia.org/wiki/Linux
- http://en.wikipedia.org/wiki/Unix_philosophy
- http://en.wikipedia.org/wiki/Unix_architecture
- General Download links for all flavors of linux and its ISO images -> http://www.linuxhelp.net/linux_downloads/
- Linux File permissions — in a neatly explained manner —> http://www.unix.com/tips-tutorials/19060-unix-file-permissions-printfriendly.html
Debian
- http://en.wikipedia.org/wiki/Debian
- Debian Vs Non-Debian -> http://www.gnulinux.in/blog/gnulinux/debian-vs.-other-gnu/linux-distros
- Getting to Know Debian -> http://www.sitepoint.com/print/getting-know-debian/
Slackware
- http://en.wikipedia.org/wiki/Slackware
- http://www.howtoforge.com/slackware_vmware_esx_server
- Slackware Download -> http://www.slackware.com/getslack/
Ubuntu
- http://ubuntu-assist.com
- http://www.ubuntuforums.org
- http://www.ubuntuhq.com/wiki/index.php/Ubuntu_Howtos
CygWin
Information about Cygwin goes here
Commands
All linux commands are discussed here
SED
SED Tutorial is given here -> http://www.grymoire.com/Unix/Sed.html
System Administration
- 20 Linux System Monitoring Tools Every SysAdmin Should Know -> http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
- UNIX network analysis (Understanding your UNIX system network configuration) -> https://www.ibm.com/developerworks/aix/tutorials/au-unixnetworkanalysis/?S_TACT=105AGY05&S_CMP=bhamuthu&ca=deb-in-bhamuthu
- Tips for Optimizing Linux Memory Usage -> http://www.linuxjournal.com/article/2770
Understanding the Path Variable
As in DOS, the shell uses the PATH variable to locate a command. PATH contains a list of directories separated by colons:
echo $PATH
/bin:/usr/bin:/usr/local/bin
When you enter a command, the shell looks in each of the directories specified in PATH to try to find it. If it can't find the command in any of those directories, you'll see a "Command not found" message.
If you decide to put your own programs in a bin directory under your home directory, you'll have to modify the path to include that directory, or the system will never find your programs (unless you happen to be in that directory when you enter the command). Here's how to change your PATH variable so it includes your personal bin directory:
PATH=$PATH:$HOME/bin
So if PATH was set to /bin:/usr/bin:/usr/local/bin beforehand, it would now have the value /bin:/usr/bin:/usr/local/bin:/home/hermie/bin.
Creating Your Own Shell Variables
If you are a programmer, you'll find it handy to create your own shell variables. First issue the command
code=$HOME/projects/src/spew
and then, regardless of what directory you are in, you can issue
cd $code
to pop over quickly to the directory containing the source code for that way-cool spew program you're developing. (The cd command means "change directory.")
A variable assignment like this will work just fine, but its scope (visibility) is limited to the current shell. If you launch a program or enter another shell, that child task will not know about your environment variables unless you export them first.
Unless you know for sure that an environment variable will have meaning only in the current shell, it's a good idea to always use export when creating variables to ensure they will be global in scope—for example,
How to find the DNS name in Linux
You can issue commands like domainname, dnsdomainname [it definitely works!]
Some good links are here:
* From About.com is here
* Further more, a google search on linux command to find the DNS name works :). It is here
How to find the gateway in Linux
Type "route -n" command in the shell.
How to get the environment, cpu details in Linux
Type "more /proc/cpuinfo" in the shell. 'cpuinfo' is the executable located in the /proc directory
The sample info i got it from LMRA Prod Was-P machine is here:
lmrwas-p:~ # more /proc/cpuinfo
vendor_id : IBM/S390
# processors : 1
bogomips per cpu: 1992.29
processor 0: version = FF, identification = 011EBC, machine = 2086
How to get the OS (specific flavour) and its version in Linux
Type "more /etc/issue" in the shell. It will give you the specific flavor of linux got installed and its version.
The sample info i got it from LMRA Prod Was-P machine is here:
lmrwas-p:~ # more /etc/issue
Welcome to SUSE LINUX Enterprise Server 9 (s390x) - Kernel \r (\l).
How to get the memory usage in Linux
Type "more /proc/meminfo" in the shell. It will give you the detailed list of memory like its total size available, memory used at the moment, free memory, etc .,
The sample info i got it from LMRA Prod Was-P machine is here:
lmrwas-p:/home/lmrschdlr/EMSAPPSchedular # more /proc/meminfo
MemTotal: 2050136 kB
MemFree: 947868 kB
Buffers: 13836 kB
Cached: 141712 kB
SwapCached: 4412 kB
Active: 887624 kB
Inactive: 79608 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 2050136 kB
LowFree: 947868 kB
SwapTotal: 2403256 kB
SwapFree: 2391668 kB
Dirty: 296 kB
Writeback: 0 kB
Mapped: 823904 kB
Slab: 112928 kB
Committed_AS: 1437476 kB
PageTables: 2692 kB
VmallocTotal: 4292861952 kB
VmallocUsed: 3152 kB
VmallocChunk: 4292858276 kB
One more thing, for a short output, you can use "free -m" command, it will give you the precise output of memory and swap spaces. Remember: The size given are in KBs. You got to convert them into MBs and GBs as required. :)
lmrwas-p:~ # free -m
total used free shared buffers cached
Mem: 2002 1087 914 0 14 138
-/+ buffers/cache: 934 1067
Swap: 2346 11 2335
How to sort the files based on the size?
* http://www.unixforum.co.uk/index.php?showtopic=7724
* http://www.yaroman.com/2007/08/14/how-to-sort-files-and-folders-by-size/
* http://www.ducea.com/2006/05/14/tip-how-to-sort-folders-by-size-with-one-command-line-in-linux/
* http://www.ubuntugeek.com/how-to-sort-files-and-folders-by-size.html
* http://puretechie.blogspot.com/2007/03/how-does-one-sort-files-based-on-size.html
* http://adminlinux.blogspot.com/2006/12/sort-folders-by-size-with-one-command.html
How to avoid the control characters when executing a shell script?
At times we get an error like /bin/bash^M: bad interpreter: no such file or directory when we run a shell script or any executable in Linux. The reason being the file would have got opened/edited in Windows OS there some control characters like Ctrl+M got added at the end. The interpreter (eg. bash) could not locate such characters in Linux OS. Hence the error. You can avoid this by running "dos2unix <filename>" which removes those characters.
Have a look at this url for more info: http://www.linuxquestions.org/questions/slackware-14/binbashm-bad-interpreter-no-such-file-or-directory-461400/
How to clean up the disk in Unix box when the root partition becomes full?
It is a tedious task of any Administrative activity. Have a look at the nice url -> http://www.linuxquestions.org/questions/slackware-14/root-partition-full-644838/
How to find the previous commands typed?
* You can can get to know the previous commands one by one by making use the arrow keys (up and down arrow keys).
* If you want to see the whole set of commands executed earlier, you can use history command.
* You can even set a limit on it by using "set history=<numberOfCommandsToStore>"
How to find files based on date?
* Good link with explanation -> http://www.cyberciti.biz/tips/shell-script-to-open-files-based-on-date.html
- General commands that help you navigate -> http://www.cyberciti.biz/tips/linux-commands-to-help-you-navigate.html
How to run a non-interactive command over web?
Try using 'wget' command. It is explained here -> The non-interactive network downloader http://linux.die.net/man/1/wget
How to check the file size omitting the sub-directories?
You can use the following command: "du -h | grep -v '/' | awk '{print $1}' "
- You can also have a look at this URL -> Root folder maintenance at http://www.unix.com/sco/38257-root-folder-space-maintenance-sco.html
- find command for the same -> "find / -type f -size +20000k > outputfiles.txt" —> to list out the files in outputfiles.txt having >20 MB Size
- du command -> //"du -a |sort -r -n >/u/file.list" —> The output of this is a list of the files and directories on the entire system sorted in descending order by size. Using this you should be able to find files that you didn't know existed inadvertently saved in the wrong directory), and which files are growing (have a recent file date).
How to find the file type in linux?
- see the file command
How do I list only directories?
- http://www.linuxquestions.org/questions/programming-9/how-can-i-list-directories-only-in-linux-375219/
- http://www.cyberciti.biz/faq/linux-list-just-directories-or-directory-names/
- http://www.computerhope.com/unix/uls.htm [ls -d */]
- http://www.amjith.blogspot.com/2005/01/directory-listing-in-linux.html
- http://linux.byexamples.com/archives/314/how-to-list-just-directories-the-correct-way/
How do I search for a specific pattern in a file?
You can use 'grep' command as follows:
"grep <patternToSearch> <fileName>"
It lists the matching lines having the <patternToSearch> in it. You can look for options about case sensitive.
How do I search for a specific pattern in all the files in a directory?
"grep <patternToSearch> * "
—> '*' - for all files in the present directory
You can combine/redirect the output to "uniq" command or "sort -u" to get the unique entries if at all a single file having more than one entry matching with the same pattern. It would be as follows
"grep <patternToSearch> * | sort -u" "grep <patternToSearch> * | uniq"
How do I get only time from the 'date' command?
You can use the 'cut' command to extract a specific field/column/character from the set of text. The command would be
date | cut -d' ' -f4
The output displayed would be
11:34:49
If you don't want the semicolon (:) [typical usage would be when you would like to get the timestamp and append it to the filename as <fileName_HHMMSS.txt>], you can use 'tr' command (translate) with -d option (to delete) for ":" as follows:
date | cut -d' ' -f4 | tr -d ':'
The output would be
113449
How to extract a specific field in ls -ltr command — say only the user or group?
You can use the combination of 'tr' and 'cut' commands as follows: looks like a crude/indirect way (got to know from Supreeth of THBS)
ls -ltr | tr -s ' ' ? | cut -d? -f3
The above command translates the whitespaces with a question mark (?) using 'tr' command with '-s' option and then uses 'cut' command for extracting the 3rd field (-f3) in the output using the delimiter (-d?) as the question mark.
You can use -f4 for getting the group name.
How to set the system date/time?
http://www.linuxsa.org.au/tips/time.html
How to extract all public methods in set of .java files?
This was basically asked in BOJUG google groups and the below ones are the suggestions given by the user.
1.
% find . -name \*.java -print | xargs grep "^public "
2. You could get a list of all the files in the source folders and use reflection to figure out public methods.
Class c = Class.forName(filePathCorrectlyConvertedToFQName); Method m[] = c.getMethods();
Also have a look at http://java.sun.com/developer/technicalArticles/ALT/Reflection/
If I were in a hurry and if all I wanted was to estimate, I would use Simran's method. (the above one of using 'find' command)
How to Copy Just the Last Two Days of Files to Another Directory
http://www.howtogeek.com/wiki/Copy_Just_the_Last_Two_Days_of_Files_to_Another_Directory
How to set/change the Default Gateway in a Linux machine
- http://www.wallpaperama.com/forums/change-default-gateway-linux-command-t303.html
- Edit the ('vi') the '/etc/sysconfig/network' file and see the entries
- Add the Gateway of your choice as 'GATEWAY=210.96.156.101' in the file
- Save the file (':wq' in VI)
- Alternate: Use the route command as follows
[[code type="java"]]
route add default gw 192.168.0.1
[[/code]
- Linux setup default gateway with route command -> http://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/
- How do I find out my Linux gateway / router IP address? -> http://www.cyberciti.biz/faq/how-to-find-gateway-ip-address/
- Define a static IP on Linux, and assign a Default Gateway -> http://www.go2linux.org/how-to-configure-ip-default-gateway-dns-linux-command-line
- route Linux Commands -> http://www.hscripts.com/tutorials/linux-commands/route.html
- Red Hat / CentOS Linux Setting a Default Gateway -> http://www.cyberciti.biz/faq/howto-rhel-fedora-linux-setup-default-gateway/
How do run a command as a specific user in Unix via my Java Program?
- http://www.coderanch.com/t/110254/Linux-UNIX/setuid
- http://www.coderanch.com/t/461765/Java-General/java/Change-UNIX-user-JAVA
Shell Scripting
Some good links:
- For bash, http://bashcurescancer.com/
- Excellent Bash Scripting Tutorial is here http://www.linuxconfig.org/Bash_scripting_Tutorial
- An Excellent Article from IBM, Bash By Example Series is here
- Part 1 is here http://www.ibm.com/developerworks/library/l-bash.html
- Part 2 is here http://www.ibm.com/developerworks/library/l-bash2.html
- Part 3 is here http://www.ibm.com/developerworks/library/l-bash3.html
- About Bash in Wikipedia is here http://en.wikipedia.org/wiki/Bash
- An excellent Command line quick reference is http://www.pixelbeat.org/cmdline.html
- GNU Bash Reference Manual is http://www.freetechbooks.com/about180.html&highlight=bash
- The same in organized manner, The GNU Bash Reference Manual http://www.network-theory.co.uk/docs/bashref/
- Bash Tutorial Excellent is here http://csdir.org/tutorials/bash-tutorial/
- Bash Guide for Beginners from The Linux Documentation Project is here http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
- Advanced Bash Scripting from The Linux Documentation Project is here http://tldp.org/LDP/abs/html/index.html
- Bash Beginner's tutorial -> http://linuxreviews.org/beginner/Bash-Beginners-Guide/
- Advanced Bash Scripting -> http://linuxreviews.org/beginner/abs-guide/
- Bash Shell Reference -> http://linuxreviews.org/beginner/bash_GNU_Bourne-Again_SHell_Reference/
- Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook is http://www.usd.edu/~sweidner/lsst/
- SHELLdorado - your UNIX shell scripting resource is here http://www.shelldorado.com/
- Advanced Bash scripting Guide is here http://www.tldp.org/LDP/abs/html/
- Using Bash History More Efficiently: HISTCONTROL -> http://www.linuxjournal.com/content/using-bash-history-more-efficiently-histcontrol
- Using Bash History More Efficiently -> http://www.linuxjournal.com/content/using-bash-history-more-efficiently
- My Favorite bash Tips and Tricks -> http://www.linuxjournal.com/article/7385
- Csh considered harmful -> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
https://fedorahosted.org/liveusb-creator
Shell Scripting - HowTos
- How to assign a output of a command to a variable?
- You have to embed the command within a backtick (with tilde key).
Example :
myOutput = `basename $filename .bat` cat myOutput
The above code extracts the basename of a file (without any extension) and assigns the result of the command to the variable 'myOutput'.
- How to get the filename without extension?
- How to get the extension of a filename?
- How to get the list of files in a specific directory which you pass an argument?
Cron Jobs
- How do I add jobs to cron under Linux or UNIX oses? -> http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
- http://www.d9x.net/linux/guides/crons.php
- http://troy.jdmz.net/cron/
- http://www.howtoforge.com/a-short-introduction-to-cron-jobs
- http://www.unixgeeks.org/security/newbie/unix/cron-1.html — Excellent
Tips and Tricks
- The main articles link on linux on howtogeek.com -> http://www.howtogeek.com/tag/linux/
- Display Number of Processors on Linux -> http://www.howtogeek.com/howto/ubuntu/display-number-of-processors-on-linux/
- Secure your Server with iptables -> http://www.sitepoint.com/print/secure-server-iptables/
- Use Webmin for Linux Administration, Parts 1 and 2 -> http://www.sitepoint.com/print/webmin-linux-administration-1/
- How to Save Hours with SSI's (Server Side Includes) -> http://www.sitepoint.com/print/save-hours-ssis/
- 10 tips for sensible systems administration - Maintain your UNIX systems —> http://www.ibm.com/developerworks/aix/library/au-sensiblesysadmin/index.html
IP tables
- What are ip tables? http://onlineappsdba.com/index.php/2008/04/13/iptables-linux-based-firewall/
VI editor
- Vi Editor Tutorial -> http://www.linuxclues.com/articles/08.htm
- Linux Vi Cheatsheet Technique -> http://www.gentoo.org/doc/en/vi-guide.xml
Misc
- Linux File Server Tutorial -> http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/appa.html
- Understanding UNIX / Linux filesystem directories -> http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-directories.html
- Understanding UNIX / Linux filesystem Inodes -> http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-inodes.html
- How Do I Copy and Rename Linux Files? -> http://lowfatlinux.com/linux-copy-files-cp.html
- Symbolic Link -> Wikipedia —> http://en.wikipedia.org/wiki/Symbolic_link
- Understanding UNIX / Linux symbolic (soft) and hard links -> http://www.cyberciti.biz/tips/understanding-unixlinux-symbolic-soft-and-hard-links.html
- Q & A: The difference between hard and soft links —> Excellent -> http://linuxgazette.net/105/pitcher.html
- redirect to same filename without extension -> http://www.daniweb.com/forums/thread59931.html
- Unix File Permissions — an excellent article -> http://www.unix.com/tips-tutorials/19060-unix-file-permissions.html
- /dev/null - Use to send unwanted output of program -> http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/ch04sec1.html
- Assigning output to a variable -> http://www.unix.com/shell-programming-scripting/58548-assigning-output-variable.html
- how to assign an output to a variable -> http://www.unix.com/unix-dummies-questions-answers/19941-how-assign-output-variable.html
- Assigning output of command to a variable in shell -> http://www.unix.com/shell-programming-scripting/55020-assigning-output-command-variable-shell.html
- Assigning output of command to a variable -> http://www.unix.com/shell-programming-scripting/28634-assigning-output-command-variable.html
- Command output to a variable. -> http://www.unix.com/shell-programming-scripting/16066-command-output-variable.html
- assigning command output to a shell variable -> http://www.unix.com/shell-programming-scripting/39735-assigning-command-output-shell-variable.html
- Print a Tab —> http://www.unix.com/unix-dummies-questions-answers/101438-print-tab.html
- View what users are / was logged on a system -> http://linuxreviews.org/beginner/viewusers/
- Shutdown / Reboot commands -> http://linuxreviews.org/beginner/shutdown_and_reboot/
- Beginners: Learn Linux -> http://linuxreviews.org/beginner/
- Tao of Regular Expressions —> http://linuxreviews.org/beginner/tao_of_regular_expressions/tao_of_regular_expressions.html.en
- How To Get Filename Without The Extension! -> http://fixunix.com/ms-dos/343166-how-get-filename-without-extension.html
- any way to get real tab chars in console output? -> http://fixunix.com/ms-dos/519284-any-way-get-real-tab-chars-console-output.html
- redirect to same filename without extension -> https://www.linuxquestions.org/questions/linux-software-2/redirect-to-same-filename-without-extension-497013/
- Unix lp command -> http://www.computerhope.com/unix/ulp.htm
- Unix pr command -> http://www.computerhope.com/unix/upr.htm
- How to rename a file in Linux -> http://nixcraft.com/linux-software/11780-how-rename-file-linux.html
- Short Tip: Get file extension in Shell script -> http://liquidat.wordpress.com/2007/09/29/short-tip-get-file-extension-in-shell-script/
- Getting yesterday or tommorrow's date with date command -> http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html
- Copy Your Linux Install to a Different Partition or Drive -> http://www.linuxjournal.com/content/copy-your-linux-install-different-partition-or-drive
- Boot with GRUB - http://www.linuxjournal.com/article/4622
- Using dos2unix and unix2dos video -> http://www.linuxjournal.com/video/using-dos2unix-and-unix2dos
- Installing Webmin: for admins that like it GUI -> http://www.linuxjournal.com/video/installing-webmin-admins-it-gui