Posts

Showing posts with the label sysadmin

Create a Symlink as a Workaround for Partition Full Error

Sometimes, a mounted partition does not have enough space, and it may take time to expand the LVM volume, if there is not currently enough physical space available, and a separate team handles storage.  Of course making a separate partition is a more proper fix, and LVM is flexible enough to accommodate the changes, but sometimes space is filling up, and something has to be done right away.  Maybe /var/log, or /opt is filling up, and you did not think ahead to make it a separate partition. As a quick workaround, it is fairly common to use a symbolic link, or as sysadmins affectionately call it, a symlimk. Let's say an application wants to install under /opt, and you are out of space in /opt, but have plenty of space in /app.  You can use a symlink to trick the system into thinking that it is using /opt, when in fact it is using /app/opt. I like to perform a directory move and symlink creation at the same time.  Note that both /opt and /app already exist, but w...

Data Recovery: 5 Things You Must Know

Image
Hard drive data recovery is one of the most difficult tasks a sysadmin can attempt to perform, so it should be considered a last resort that, after many frustrating hours, may not even work at all. Data Recovery or Disaster Recovery can be thought of in several categories, and it is important to have a plan in place, and know the options before resorting to one of your local hard disk data recovery services. Many people fail to consider the value of their data until it is too late. This article discusses general principles, with some specific examples from experience with Novel, Microsoft, and Linux operating systems. Detailed tool discussions will be reserved for separate posts. Here is a short list of categories, roughly in order of increasing level of difficulty to recover. Backups and off-site storage RAID Documents File Systems Data Recovery from Hard Drives There is software available that can recover from several types of failures, but it does not always work when ther...

Vim Tips -- Search and Replace

Image
Did you ever wonder if there was an easy way to send an example file for someone to look at, but still keep your private information safe? Sure you can use a sed, or perl one-liner, as I discussed: using-bash-and-sed-to-modify-text-file.html , but why not use search and replace in vi / vim before publishing your info? That way you can see exactly what you are changing. Remember, while vim is installed by default on most Linux distros, is also available for Windows, and it is free -- http://www.vim.org Suppose you have part of a log file, or nmap output that contains real hostnames, a real domain name, and real IP addresses. You want someone to help you troubleshoot something, but you don't what to give the real info for everyone to see. Start with the info in a text file, such as this: Host realhost-1.realdomain.com (192.168.0.54) appears to be up. Host realhost-2.realdomain.com (192.168.0.55) appears to be up. Host realhost-3.realdomain.com (192.168.0.56) appears to be up. Host...

Ping Multiple Hosts Using Bash Nmap and Fping

Image
I explained how to get a list of hosts using nmap -- using-nmap-to-generate-host-lists.html , but here is another look at the subject. The question is, how do I ping multiple hosts to find out which ones are down? Sure this could be considered a topic of system monitoring, but maybe you just want to reboot a bunch of machines, and make sure they all come back online. This quick check will tell you whether there is a problem or not. Here are three methods for pinging a list of hosts: 1.) for host in `cat all.txt `;do ping -c 1 $host; done 2.) nmap -sP -R -iL all.txt 3.) sudo fping -u < xyz/all.txt First, we assume that you have a text file named all.txt that contains a list of hostnames, one per line. Obviously, the examples here contain fake hostnames, domain names and IPs, as described in another article about vi: vim-tips-search-and-replace.html . --- all.txt --- xyz-1 xyz-2 xyz-3 xyz-4 xyz-5 xyz-6 xyz-7 xyz-8 --- end all.txt --- 1.) Use a for loop in ...

Beginner's Guide to the Vi editor

Image
The article linked below is a nice introduction to the Vi editor. People often ask why they have to learn vi, or vim. One important reason is that it is the editor most likely available on any linux or unix system you may have to manage as a sysadmin. Less experienced sysadmins may say that they can just install joe, or pico, or something similar -- until I show them 1200 linux boxes that we have to manage! Anyway, once you have the basics, you can add more knowledge as you go. First realize that there are two modes - command mode, and editing mode. "i" puts vi into editing mode, and [esc] goes back to command mode. You can get by with just a few commands at first: vi file.txt i (insert -- go into editing mode) [esc] (move around) [esc]:wq (save) [esc]:q! (quit without saving) read more | digg story Links: http://www-acs.ucsd.edu/info/vi_tutorial.php http://www.viemu.com/vi-vim-cheat-sheet.gif

Use CheckInstall Instead of Make Install

Did you ever look for a binary, and as a last resort download the source to compile yourself?   Of course you were disappointed that the program would not be part of your package management system. Usually you have to run something like this:   ./configure   make   make install An easy way to create an .rpm or .deb file from source is to run checkinstall instead of "make install" during the standard install from source. http://freshmeat.net/projects/checkinstall -- CheckInstall Freshmeat Page http://checkinstall.izto.org -- CheckInstall Home Page CheckInstall keeps track of all files installed by a "make install" or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution.

Blogger Digest: Using VNC And Redhat Linux

VNC is an excellent way to remote control linux and Windows machines. Here is a description, and links to the programs. Blogger Digest: Using VNC And Redhat Linux x11vnc official site Real VNC Server official site TightVNC TightVNC software UltraVNC UltraVNC software

RHCE Study Notes - HTTP

Image
These RCHE study notes were designed to be brief reminders of what you should already be familiar with. This topic covers HTTP server configuration. One thing to be aware of when working with Apache and the 2.6 kernel is SELinux. Overview of SELinux SELinux, is a Mandatory Access Control (MAC) security system for Linux based on the domain-type model. It was written by the NSA ( http://www.nsa.gov/selinux/ ) and is comprised of a kernel module (included in all 2.6 kernels), patches to certain security related applications, and a security policy. More info: http://www.redhat.com/magazine/001nov04/features/selinux/ Study Notes Here are the brief steps from my RHCE study guide to help you remember the steps to configure a virtual host, and configure permissions. * HTTP/HTTPS install httpd, check context with ls -Z   Q: Create a virtual host www1.example.com w/ subdirectory /var/www/html/www1   A:    1) install httpd, modify /etc/httpd/conf/httpd.conf file  ...

How to Hide Files and Directories in Linux

Image
In Linux, directories are not accessible until the device is mounted. This is usually done at startup by the mount command which uses the /etc/fstab file. Files that start with a dot "." are hidden, but not completely (you can do ls -a to see the files). An example is the ~/.bashrc file. You can also hide files in a directory name that starts with a dot, e.g. ~/.ssh Now for the real trick Entire directories can be hidden, simply by mounting another device on top of the directory. The original files will still be in tact, but not visible until the device is remounted. First, find a device that is available to mount (boot is nice, because it is usually small). $ mount /dev/hda1 on /boot type ext3 (rw) ... etc... Then make your stealth directory, copy files to it, and mount a directory over it. $ cd /mnt $ mkdir stealth $ touch /mnt/stealth/somefile.txt $ ls /mnt/stealth/ somefile.txt $ mount -t ext3 /dev/hda1 /mnt/stealth ls /mnt/stealth/ config-2....

Top Free Web Site Analysis Programs

There are two basic categories for web site tracking. 1. Online (Embeded Tracking Code) 2. Log Analysis (Software) Onine This type of analysis has the advantage that nothing needs to be installed on the web server. The disadvantage is that every page requires modification. That is not much of a problem for blogs, or generated content, but it can be tedious to modify a large number of pages by hand. Google analytics is free, very simple to use, and produces excellent reports. Here are the instructions from their site: https://www.google.com/support/analytics/bin/answer.py?answer=27323&hl=en_US How do I track a new website? There are two simple steps required to start tracking a new website: the creation of a new website profile, and the addition of Analytics tracking code to all of the pages you wish to track. Create a new profile 1. From the Analytics Settings page, click Add Website Profile 2. Select Add a Profile for a new domain 3. Enter the URL of the site you will be tra...

Top 7 Things System Administrators Forget to Do

Out of the plethora of chores that we do each day, which ones make up the top seven activities of forgetful system administrators? To begin, you might ask yourselves if the answer is quantitative or qualitative. Let's think about it for a minute. Forgetting to Delete a Former User's Account Forgetting to Regularly Search for Rootkits Forgetting to Use a Trouble Ticket Tracking System Forgetting to Set Up Technical Documentation and Creating a Knowledge Base Forgetting the Risks of Flash Memory Drives Forgetting to Manage Partial Root Access Forgetting Courtesy read more | digg story

10 Reasons Why It Doesn’t Pay To Be “The Computer Guy”

Scroll down for the top 10 list. From http://www.lifereboot.com read more | digg story

How to Turn on IP Forwardarding

Image
IP Forwarding Effectively makes a Linux box act as a router Is usually used with two network interfaces (one internal, and one external) Can be used with firewall services and is often used for NAT Steps to Turn on IP Forwarding  1) Modify /etc/sysctl.conf      vi /etc/sysctl.conf      add this line:      inet.ipv4.ip_forward=1  2) Make the Change Active      sysctl -p  3) To View Current Settings:      sysctl -a | grep ipv4 More info can be found on the redhat site: https://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/security-guide/s1-firewall-ipt-fwd.html We'll leave firewall rules for another topic... rhce linux

How to Change the Root Password to Get Into a Linux Box

Image
This procedure assumes you have console access, and are authorized to make changes to accounts on the machine, including root. If you own the machine, you can boot into single user mode, and change the password, or create an account. If using grub (you should see a blue bootup screen), press "a", "space", "1", "enter" a 1 That will boot to single user mode. Then you can change the root password passwd Then reboot Ctrl-Alt-Del You should create user accounts other than root. Use the useradd command. useradd someone passwd someone rhce linux

RHCE Study Notes - SMTP

Image
Study notes for any exam are difficult enough to find, but RHCE material seems even more scarce. This article tells how to prepare for one of the objectives, which is configuration of an SMTP server. RHCE Study Notes I wrote up some study notes as I was preparing for the RCHE exam. Here are some quick notes based on the official RedHat objectives , labs, and possible questions I thought might be reasonable requests. SMTP Related Questions install sendmail, sendmail-cf, sendmail-doc (optional) Q: Configure mail server to accept internet email A: modify /etc/mail/sendmail.mc 1) cd /etc/mail 2) vi /etc/mail/sendmail.mc search for 127.0, put dnl at the front of the line 3) make or m4 sendmail.mc > sendmail.cf service sendmail restart Q: Mail alias A: modify /etc/aliases, run newaliases Q: Receive mail for DomainX.example.com A: modify sendmail mc as above, and add domain to /etc/mail/local-host-names ...

How to Run a Bash Command on All Items in a List

Image
For Linux / Unix Follow as instructed For Windows Download cygwin from http://cygwin.com For instructions, see this article: http://systemnotesorg.blogspot.com/2007/04/use-cygwin-to-run-linux-on-windows.html Two Easy Steps for One-Liners e.g., you have a list of servers, and would like to do something, such as ping each one, or check their IP address. Here is a quick two-step process, with a one-line shell script that can be run from the command line. 1) Create a Text file, with one hostname per line 2) Run a for loop on the file $ cat servers.txt server01 server02 server03 $ for host in `cat servers.txt`;do host $host;done server01.example.com has address 10.10.10.10 server02.example.com has address 10.10.10.11 server03.example.com has address 10.10.10.12 $ If you want different output, you can use awk, but that's another topic. Notice a few things about this one line script. 1) Each command is separated by a semicolon ";" 2) The ba...

Using bash and sed to Modify a Text File

Image
This shell script demonstrates how to write to a text file, and then modify the contents. #!/bin/sh # modfile.sh # by ScottM, 04/12/2007 # demonstrates writing text to a file, and then using sed to modify it. TESTFILE=test.txt FRUIT=banana # add some content to the file (note: file will be overwritten) echo "apple" > $TESTFILE # modify the content sed -e "s/apple/& $FRUIT/g" -i $TESTFILE # sed uses the "s" option, which uses regular expressions to search and replace text # "s/apple/" means search for any lines that contain the characters "apple" # "& " means use the results of whatever was found # "/& $FRUIT/g" -- replace "apple" with "apple banana", # the g is for global, or all lines containing the pattern # output: # $ cat test.txt # apple banana # $ Sed One Liner This is really only a one line script, commonly referred to as a on-liner, so we don't really need a...

Using nmap to Generate Host Lists

Image
An easy way to get a list of hosts from a single domain that you are a part of, is to query DNS host -l mydomain.com But that is not always practical. Sometimes you have machines that are in different domains, but they all are part of a network you manage. Rather than trying write a script that pings hosts and reports the output, just use nmap for a very fast scan. To scan all hosts in a list of subnets 1) Create a subnets.dat file with one subnet on each line: $ cat subnets.dat 192.168.0.* 192.168.1.* 2) Run nmap with the subnets.dat file as input $ nmap -sP -R -iL subnets.dat Reading target specifications from FILE: subnets.dat Starting nmap V. 3.00 ( www.insecure.org/nmap/ ) Host (192.168.0.0) appears to be down. Host box1.mydomain.com (192.168.0.1) appears to be up. Host box2.mydomain.com (192.168.0.2) appears to be down. Host box3.mydomain.com (192.168.0.3) appears to be up. Host (192.168.0.4) appears to be up. ... Notice how names are resolved ...

Network Config

Image
How Do I Configure Networking in RedHat Linux? Depending on the version of RedHat, or Fedora: redhat-config-network system-config-network bash-2.05b$ which redhat-config-network /usr/bin/redhat-config-network bash-2.05b$ Network Related Files: /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network /etc/hosts /etc/resolv.conf For more details, remember that the Red Hat Manuals are available online: http://www.redhat.com/docs/manuals Network Info: http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/ref-guide/s1-networkscripts-interfaces.html rhce linux

Simple HD Config Question

> From: Brian > Sent: Thursday, March 22, 2007 2:41 PM > To: Scott > Subject: Simple HD config Question > > > When you have a desktop with a diagnostic partition on the hard drive (like HP or DELL) can > you keep the diagnostic partition or do you have to wipe it? If you do keep it do you have to > use a special boot loader to allow you to still access the partition? > > > > -Brian F. -------------------------------------------------------------------------------- You don't really need it. The utilites are usually the same ones that are on the CD. Dell likes to make it easier for their support, since users lose CDs, and have no clue on how to download and burn another one. Compaq had a requirement that the SmartStart CD be used in order to install NT, but that is no longer required. If you run fdisk, and reformat the drive, you can reclaim the space. - scottm