Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-31-2006, 03:34 PM
|
#1
|
Member
Registered: Dec 2005
Location: NC, USA
Distribution: (K)ubuntu
Posts: 139
Rep:
|
A page of Linux commands/utilities
Here's a list of Linux commands/utilities that my coworkers and I have compiled. I'm just putting it out here for reference for anyone interested. Feel free to add any modifications you want.
Quote:
<html>
<head>
<title>Linux Commands</title>
</head>
<body>
<p>This is a group of Linux command line tools that you might need.</p>
<br>
<br>
<h1>Table of Contents</h1>
<br>
<h3>0-9, punct.</h3>
<br>
<a href="#procusage">/proc usage</a>
<br>
<h3>A</h3>
<br>
<a href="#dbbackup">Access a backup for the DB server</a>
<br>
<a href="#addIP">Add an IP address to a NIC</a>
<br>
<a href="#addftp">Add FTP User</a>
<br>
<a href="#lfarchive">Archive of large folder</a>
<br>
<h3>C</h3>
<br>
<a href="#processports">Check for processes listening ports</a>
<br>
<a href="#sqlintegrity">Check mysql data integrity</a>
<br>
<a href="#nicspeed">Check NIC port speeds</a>
<br>
<a href="#biosv">Check SCSI Raid Controller bios version</a>
<br>
<a href="#smb2win">Connect to a Windows share with Samba</a>
<br>
<a href="#copyperm">Copy permissions from one folder to another</a>
<br>
<h3>D</h3>
<br>
<a href="#dbsteps">DB migration steps</a>
<br>
<a href="#rmsubfiles">Delete files from subdirectories.</a>
<br>
<a href="#u2dpacks">Determine what packages are available on Up2Date</a>
<br>
<a href=#dnslookup">DNS Lookup</a>
<br>
<h3>F</h3>
<br>
<a href="#avpack">Find out what packages are available</a>
<br>
<a href="#forcelogrotate">Force log rotate to run</a>
<br>
<a href="#runurchin">Force Urchin to Run ( Keep existing schedule )</a>
<br>
<h3>G</h3>
<br>
<a href="#binstrings">Get the strings out of a binary</a>
<br>
<a href="#binstrings">Get the strings out of a binary</a>
<br>
<a href="#sqlaccess">Grant Access on MYSQL DB</a>
<br>
<a href="#invgrep">Grep all but</a>
<br>
<a href="#greplines">Grep entire lines containing the following</a>
<br>
<h3>I</h3>
<br>
<a href="#installrpm">Install a given packagae from the Red Hat RPMS</a>
<br>
<h3>L</h3>
<br>
<a href="#packcontents">List contents of package</a>
<br>
<a href="#lsusrsuage">List of usage by user for the root directory.</a>
<br>
<a href="#instdrmps">List what RPMs installed on the system.</a>
<br>
<a href="#locateandcopt">Locate certain files and make a copy of files and store in the their original folders.</a>
<br>
<h3>M</h3>
<br>
<a href="#checku2d">Make sure we are up to date with packages</a>
<br>
<a href="#date">Manipulate the date</a>
<br>
<a href="#MSC">Multi Screen Control in shell - watch other users</a>
<br>
<h3>P</h3>
<br>
<a href="#processes">Process list with child processes</a>
<br>
<h3>R</h3>
<br>
<a href="#rhbf">Red Hat Bug Fixes</a>
<br>
<a href="#rmstartup">Remove service from startup</a>
<br>
<a href="#renameext">Rename file extentions</a>
<br>
<a href="#frestore">Restore files for server 4</a>
<br>
<h3>S</h3>
<br>
<a href="#talktoothers">Say junk to other people</a>
<br>
<a href="#accessdeets">See file access details ( Created/Mdified Dates )</a>
<br>
<a href="#sshact">See SSH activity</a>
<br>
<a href="#setdate">Setting the date</a>
<br>
<a href="#sshtimeout">SSH Server client timeout control</a>
<br>
<a href="#opbyproc">Show open files by process</a>
<br>
<a href="#logins">Show who logged in and when</a>
<br>
<a href="#killse">Shut off SE Linux</a>
<br>
<a href="#ssltests">SSL Key and Cert tests</a>
<br>
<a href="#string">String replace in files</a>
<br>
<a href="#syncdirs">Sync two directories, update only if already exists</a>
<br>
<a href="#systemstatus">System Status report</a>
<br>
<h3>T</h3>
<br>
<a href="#test">Test that the</a>
<br>
<h3>U</h3>
<br>
<a href="#emailaliases">Update email aliases</a>
<br>
<a href="#kupdate">Update Kernel</a>
<br>
<h3>W</h3>
<br>
<a href="#addingIPs">When adding new IPs to the server, you need to create</a>
<br>
<a href="#activity">Who is on and what they be doin</a>
<br>
<h3><a name="#copyperm">Copy permissions from one folder to another</a></h3>
<p>===================================================<br>
Generate a script that can then be run against the dest folder<br>
<br>
find ./src -printf "chmod %p %m\n" | sed s/src/dest/g > fixdest.sh<br>
<br>
NOTE: Put #! /bin/bash on the top of the fixdest.sh<br>
<br>
chmod 700 fixdest.sh</p>
<p>====================================================</p>
<h3><a name="dbsteps">DB migration steps</a></h3>
<h5>Inside Server 4</h5>
<p>1. Shutdown Apache<br>
<br>
2. /opt/scripts/backup_mysql.sh<br>
<br>
3. cd /backup/mysql<br>
<br>
4. scp * mike@dbserver:/home/mike/mysqldata ( Make sure to clear out /home/mike/mysqldata before doing transfer )<br>
<br>
5. Make a backup of existing configs<br>
locate _webos_cfg.php | xargs cp -a --target-directory=. --parents<br>
<br>
6. Change the webos configs to have new server name<br>
locate _webos_cfg.php | xargs sed -i -e 's/localhost/db\.newfangled\.com/g'</p>
<br>
<h5>DB Server</h5>
<p>1. /opt/scripts/backup_mysql.sh<br>
<br>
2. cd /home/mike/mysqldata into gunzip all files <br>
<br>
3. Change text localhost to server4.newfangled.com and nfg user to %, in mysql.sql<br>
<br>
4. mysql -unfg -pnfg mysql < mysql.sql<br>
<br>
5. /usr/bin/mysql_fix_privilege_tables --user=nfg --password=nfg<br>
<br>
6. mysqladmin -unfg -pnfg reload<br>
<br>
7. rm mysql.sql<br>
<br>
8. rm *_moved*<br>
<br>
9. ls > list<br>
<br>
10. ../create_db.sh < list<br>
<br>
11. ../populate.sh < list<br>
<br>
12. Test websites</p>
<br>
<p>====================================================</p>
<h3><a name="addIP">Add IP Address to NIC</a></h3>
<br>
<p>As you concluded, the command you issued overwrote the original eth0 config (192.168.1.212). Here's some info on adding additional ips in Redhat:<br>
The primary ip is eth0, additional ips are numbered starting from eth0:0 (second IP, or first "additional" ip), so adding the additional ip you requested would be accomplished with an ifconfig eth0:1 192.168.1.22 netmask 255.255.255.255 up (in general, you'll want to assign your additional ips a 255.255.255.255 netmask to ensure that they don't interfere with existing subnets, although in this case 255.255.255.0 would work as well).<br>
<br>
However, this will only add the ip temporarily, and changes will be lost when the network is restarted, or the server rebooted. In order to permanently add an ip, you need to add an interface config file in the /etc/sysconfig/network-scripts directory. It is important to be careful while editing files in this directory, as this is where the configuration scripts for your various interfaces are stored, and it is fairly easy to render your server inaccessible through improper changes. With this said, you can take a look at the existing files in this directory (they will be named ifcfg-<interface> ... e.g. ifcfg-eth0, ifcfg-eth0:0, etc.)<br>
<br>
In order to permanently add the 192.168.1.22 ip as eth0:1, all you need to do is the following:<br>
<br>
create a new file 'ifcfg-eth0:1' with your favorite editor add the following lines:<br>
<br>
DEVICE=eth0:1<br>
IPADDR=192.168.1.22<br>
NETMASK=255.255.255.255<br>
ONBOOT=yes<br>
<br>
Save the file, and restart networking with a 'service network restart' (this shouldn't disrupt your ssh session, although it will freeze for a second while the primary interface restarts) and you should be all set! These files are all read on boot, so any changes here will persist across reboots.<br>
<br>
You may also notice NETWORK= or BROADCAST= lines in these files. These lines are not necessary, as they can be determined based on the ip and netmask. <br>
They are innocuous if set correctly, but if set incorrectly can cause network problems, so it's best just to leave them out.</p>
<br>
<p>====================================================</p>
<h3><a name="dbbackup">Access backup for db server</a></h3>
<p>(1) recover -s networker1-adv1.iad1.storage.rackspace.com<br>
(2) changetime sep18 (you can cd into the directory and ls to review saved files)<br>
(3) add /etc/my.cnf ( Or what ever file your are trying to restore )<br>
(4) relocate /root/restore_050919-0493 ( restore the file to this folder )<br>
(5) recover ( do the restore, this takes a while )<br>
<p>====================================================</p>
<h3><a name="killse">Shut off SE Linux</a></h3>
<p>// Temporarily<br>
echo "0" >/selinux/enforce<br>
<br>
// Permanently.<br>
vi /etc/selinux/config</p>
<br>
<p>====================================================</p>
<h3><a name="smb2win">Connect to a windows share from linux</a></h3>
<p>smbmount //servername/sharename /mnt/folder -o username=windowsuser,password=windowspwd,rw,fmask=0777,dmask=0777</p>
<br>
<p>====================================================</p>
<h3><a name="rhbf">Red Hat Bug Fixes</a></h3>
<p>https://rhn.redhat.com/errata/rhel4es-errata.htm</p>
<br>
<p>====================================================</p>
<h3><a name="locateandcopt">Locate certain files and make a copy of files and store in the their original folders.</a></h3>
<br>
<p>locate _webos_cfg.php | xargs cp -a --target-directory=. --parents</p>
<br>
<p>=====================================================</p>
<h3>string replace in files</h3>
<p>sed default_webos_cfg.php -e 's/stringtofind/replacewiththisstring/g' -i</p>
<br>
<p>=====================================================</p>
<h3><a name="emailaliases">Update email aliases</a></h3>
<p>When you add entries to the /etc/aliases file, you need to run (as root) the following command:<br>
newaliases -oa</p>
<br>
<p>=====================================================</p>
<h3><a name="string">string replace in files</a></h3>
<br>
<p>sed default_webos_cfg.php -e 's/stringtofind/replacewiththisstring/g' -i </p>
<br>
<p>=====================================================</p>
<h3><a name="processes">Process list with child processes</a></h3>
<p>ps -auxwwwwwf</p>
<p>=====================================================</p>
<h3><a name="kupdate">Update Kernel</a></h3>
<br>
<pre>
[root@db root]# up2date -l
Fetching Obsoletes list for channel: rhel-i386-es-3...
Fetching Obsoletes list for channel: rhel-i386-es-3-extras...
Fetching rpm headers...
########################################
Name Version Rel
----------------------------------------------------------
The following Packages were marked to be skipped by your configuration:
Name Version Rel Reason
-------------------------------------------------------------------------------
kernel 2.4.21 37.ELPkg name/pattern
kernel-doc 2.4.21 37.ELPkg name/pattern
kernel-smp 2.4.21 37.ELPkg name/pattern
kernel-source 2.4.21 37.ELPkg name/pattern
As you can see kernel 2.4.21.37 is available to you. You are runing 2.4.21.32
[root@db root]# uname -a
Linux db.newfangled.com 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:46:51 EDT 2005 i686 athlon i386 GNU/Linux
You can install the kernel by running
up2date -u kernel kernel-doc kernel-smp kernel-source --force
Of course a reboot will be needed for a kernel upgrade
</pre>
<br>
<p>=====================================================</p>
<h3><a name="nicspeed">Check NIC port speeds</a></h3>
<br>
<p>mii-tool</p>
<p>=====================================================</p>
<h3><a name="sqlaccess">Grant Access on MYSQL DB</a></h3>
<br>
<p>grant all privileges on DB.* to 'user'@'localhost' identified by 'PWD';</p>
<p>=====================================================</p>
<h3><a name="test">Test that the</a></h3>
<br>
<pre>
openssl rsa -noout -text -in keyfile
openssl x509 -noout -text -in certfile
</pre>
<br>
<p>Compare Modulus values to make sure they were made for each other!</p>
<br>
<p>=====================================================</p>
<h3><a name="avpack">Find out what packages are available</a></h3>
<br>
<p>up2date --showall</p>
<br>
<p>=====================================================</p>
<h3><a name="installrpm">Install a given packagae from the Red Hat RPMS</a></h3>
<br>
<p>up2date freetype-devel</p>
<br>
<p>=====================================================</p>
<h3><a name="u2dpacks">Determine what packages are available on Up2Date</a></h3>
<br>
<p>up2date --whatprovides "libpng"</p>
<br>
<p>=====================================================</p>
<h3><a name="ssltests">SSL Key and Cert tests</a></h3>
<br>
<pre>
To view the certificate:
openssl x509 -noout -text -in certfile
To view the key:
openssl rsa -noout -text -in keyfile
</pre>
<p>=====================================================</p>
<h3><a name="biosv">Check SCSI Raid Controller bios version</a></h3>
<pre>
cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: MegaRAID Model: LD0 RAID1 35073R Rev: 1L26
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: MegaRAID Model: LD1 RAID0 35002R Rev: 1L26
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
Vendor: MegaRAID Model: LD2 RAID0 70006R Rev: 1L26
Type: Direct-Access ANSI SCSI revision: 02
1L26 is several revisions old, and has been replaced by 1L37 (or possibly newer).
</pre>
<p>=====================================================</p>
<h3><a name="packcontents">List contents of package</a></h3>
<br>
<p>rpm -qlp logwatch-6.1.2-1.noarch.rpm </p>
<p>=====================================================</p>
<h3><a name="instdrmps">List what RPMs installed on the system.</a></h3>
<br>
<p>rpm -qa</p>
<br>
<p>=====================================================</p>
<h3><a name="frestore">Restore files for server 4</a></h3>
<br>
<pre>
The process I use to recover data is
(1) recover -s networker1-bas1.iad1.storage.rackspace.com
(2) changetime sep18
(you can cd into the directory and ls to review saved files)
(3) add /home/clients/crockpotcraze/crockpotcraze.newfangled.com/htdocs/store/_cart.php
(4) relocate /root/restore_050919-0493
(5) recover
</pre>
<p>=====================================================</p>
<h3><a name="sshact">See SSH activity</a></h3>
<p>/var/log/secure<p>
<p>=====================================================</p>
<h3><a name="binstrings">Get the strings out of a binary</a></h3>
<p>string</p>
<br>
<p>=====================================================</p>
<h3><a name="accessdeets">See file access details ( Created/Mdified Dates )</a></h3>
<br>
<p>stat</p>
<br>
<p>=====================================================</p>
<h3><a name="checku2d">Make sure we are up to date with packages</a></h3>
<br>
<p>up2date -l</p>
<br>
<p>=====================================================</p>
<h3><a name="syncdirs">Sync two directories, update only if already exists</a></h3>
<br>
<p>rsync -auv /home/clients/* /mnt/newide/home/clients</p>
<br>
<p>=====================================================</p>
<h3><a name="forcelogrotate">Force log rotate to run</a></h3>
<br>
<p>/usr/sbin/logrotate -f /etc/logrotate.conf</p>
<br>
<p>=====================================================</p>
<h3><a name="runurchin">Force Urchin to Run ( Keep existing schedule )</a></h3>
<br>
<p>uconf-schedule -k</p>
<br>
<p>=====================================================</p>
<h3><a name="MSC">Multi Screen Control in shell - watch other users</a></h3>
<p>screen</p>
<br>
<p>=====================================================</p>
<h3><a name="sshtimeout">SSH Server client timeout control</a></h3>
<br>
<p>Update /etc/ssh/sshd_config<br>
ClientAliveInterval=120<br>
ClientAliveCountMax=108000</p>
<br>
<p>=====================================================</p>
<h3><a name="lfarchive">Archive of large folder</a></h3>
<br>
<pre>Hello,
The 'zip' utility on your RedHat Enterprise Linux server is a part of the the "Info-Zip" package. You can read http://www.info-zip.org/FAQ.html for more information on this software. Your linux system actually does not suffer from any 2Gb file size limit. To demonstrate this, I have created a test called "hugefile.raw" in your /home/clients/archive directory which is 2.2 Gb in size. The limitation you are running into is actually specific to the zip file format, as you can read on the web page listed above. Info-Zip itself does not support creation of multi-volume archives, but the 'tar' utility does. In fact, 'tar' could easily create an archive of greater than 2Gb, so using the multi-volume options may not be necessary. As an added bonus, tar can also use an algorithm called "bzip2" which is much better than Info-Zip's compression. Here is the syntax to create a single-volume bzip2'ed tar file:
tar cjf archive.tar.bz2 huge_directory
and here is how you could make a multi-volume tar with pieces limited to 2Gb:
tar cf archive.tar -ML 2097152 huge_directory
That last command would interactively prompt you to "Prepare volume #n for `archive.tar' and hit return:". When you see that prompt, you would then need to press ctrl+z and do the following:
mv archive.tar archive.tar.n
bzip2 archive.tar.n &
fg
<enter>
in this example, "n" stands for the next consecutive archive number: 1, 2, 3, etc.
</pre>
<br>
<p>=====================================================</p>
<h3><a name="lsusrsuage">List of usage by user for the root directory.</a></h3>
<br>
<p>/home/epad/show_quota.sh </p>
<br>
<p>=====================================================</p>
<h3><a name="rmsubfiles">Delete files from subdirectories.</a></h3>
<br>
<pre>rm -rf /home/clients/*/*/{lib,bin}
find /home/clients -name vssver.scc | xargs rm
rm -f /home/clients/*/*/logs/access_log
</pre>
<br>
<p>=====================================================</p>
<h3><a name=dnslookup">DNS Lookup</a></h3>
<br>
<p>dig @ns.rackspace.com www.hitechhose.com<br>
dig @ns2.rackspace.com www.hitechhose.com</p>
<br>
<p>=====================================================</p>
<h3><a name="addingIPs">When adding new IPs to the server, you need to create</a></h3>
<br>
<p>
/etc/sysconfig/network-scripts/ifcfg-* scripts for them where '*' is the name of the interface (eth0:1, eth0:2, etc). The bootup scripts use these files to configure the interfaces when the machine reboots, so if they are not present, the IPs won't be created. I made the files and restarted network services.
</p>
<br>
<p>=====================================================</p>
<h3><a name="addftp">Add FTP User</a></h3>
<br>
<p>useradd -d /home/clients/dogwatch/www.dogwatch.com/htdocs/dl -g 50 -s /sbin/nologin dogwatchftp</p>
<br>
<p>=====================================================</p>
<h3><a name="processports">Check for processes listening ports</a></h3>
<br>
<p>netstat -lntp</p>
<br>
<p>=====================================================</p>
<h3><a name="logins">Show who logged in and when</a></h3>
<br>
<p>last</p>
<p>=====================================================</p>
<h3><a name="procusage">/proc usage</a></h3>
<br>
<p>/usr/src/linux-2.4/Documentation/filesystems/proc.txt</p>
<br>
<p>=====================================================</p>
<h3><a name="setdate">setting the date</a></h3>
<br>
<p>date 051708362004, MMDDHHMMYYYY</p>
<br>
<p>=====================================================</p>
<h3><a name="opbyproc">Show opens files by process</a></h3>
<br>
<p>lsof | grep save | grep spool</p>
<p>=====================================================</p>
<h3><a name="systemstatus">System Status report</a></h3>
<br>
<pre>
sar ( CPU usage )
sar -r ( memory usage )
</pre>
<br>
<p>=====================================================</p>
<h3><a name="activity">Who is on and what they be doin</a></h3>
<br>
<p>w<br>
<br>
who</p>
<br>
<p>=====================================================</p>
<h3><a name="sqlintegrity">Check mysql data integrity</a></h3>
<br>
<p>[sign in as root]<br>
cd /var/lib/mysql<br>
myisamchk */*.MYI ( --recover or --safe-recover to fix )</p>
<br>
<p>=====================================================</p>
<h3><a name="talktoothers">Say junk to other people</a></h3>
<br>
<p>wall</p>
<br>
<p>=====================================================</p>
<h3><a name="rmstartup">Remove service from startup</a></h3>
<br>
<p>chkconfig -del webmin</p>
<br>
<p>=====================================================</p>
<h3><a name="renameext">Rename file extentions</a></h3>
<br>
<p>for f in *.txt; do mv "$f" "$(echo $f | sed s/.txt$/.doc/)"; done</p>
<br>
chroot /mnt/oldraid bash</p>
<br>
<p>=====================================================</p>
<h3><a name="invgrep">Grep all but</a></h3>
<br>
<p> To grep everything in a file except a certian character/phrase, use "grep -f"</p>
<h3><a name="greplines">Grep entire lines containing the following</a></h3>
<br>
<p> To greo entire lines containing only the phrase you grepped for, ise "grep -Ev"</p>
<p>=====================================================</p>
<h3><a name="date">Manipulate the date</a></h3>
<br>
<p>To manupilate the date, use the "date" command. For example, date -d +%m-+%d-+%y --date '7 days ago'
</body>
</html>
|
|
|
|
03-31-2006, 03:45 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
this is the sort of thing the belongs in a wiki, and i'm sure ours already contains all this useful information. if not, you can certainly help improve the content we have there.
|
|
|
03-31-2006, 03:51 PM
|
#3
|
Member
Registered: Dec 2005
Location: NC, USA
Distribution: (K)ubuntu
Posts: 139
Original Poster
Rep:
|
I thought about putting it in a wiki, but leaving it in HTML is valuable for it's portability and non-dependance on an up-to-date local copy. Wiki services tend to use some of the HTML tags for their own formatting, which messes up the document's HTML format.
|
|
|
All times are GMT -5. The time now is 01:41 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|