Sunday, July 20, 2008

Linux Commands used in Greenland to Admin the server

For System Monitoring

-top - displays the load and memory usage of all applications and processors

-uptime - show system load and should not be over 20 (for Greenland field server)

-vmstat [-S M 5] (S M show in megabytes and 5 says update every 5 seconds) - shows memory usage.... hopefully will not use swap file because it will slow down the processing

-mpstat [-P ALL](for all processors or can put the number of the specific processor) - shows cpu usage

-df - displays mounted drives and locations

-du [-h](shows a human readable view) - displays disk usage

-SMclient - displays RAID status

-nodestatus - displays MDCE MatLab workers running

-/etc/init.d/mdce [status] - displays whether mdce is running

-/sbin/service [name] [start stop status restart] - used to access other service such as nfs, portmap ...etc

-cat /etc/fstab - lists mounts and apps that run at startup

-dmesg - kernel messages such as when you plug up a usb device

-/var/log - contains many system logs for error checking

Grub Boot Screen Options (press a at the Grub startup screen)

-Single - starts linux in single users mode with root access
-while in single user mode can type init 3 (3 being the run level you want)
-console=/dev/ttyS0 - means the output of the startup is passed to the serial port

Rsync Command options

can use the following syntax to to rsync directly to a network drive

rsync -av jpowell@ /media/usb

***If you add a / to the trailing source location, it means to copy the data in the folder....without it copies the parent folder too

autossh command

autossh -M [port1] (-M says what port 1 to monitor on) -N (dont run a command) -R [port2]:localhost:22 (open up the port 2 on the IP machine to create a tunnel to your machine (localhost) on port 22) [user@ip](ssh location you want to connect to)

autossh -M 20000 -N -R 11000:localhost:22 -p 62

person ssh in to this would use:
ssh -p 11000 localhost (this is assuming they are on

dd command options

dd -fi=input directory -do=file out

Managing users and permissions

useradd - used to add users
useradd -c "normal user" -d /home/userid -g users\
-G webadm,helpdesk -s\ /bin/bash userid
***This command creates a new user called "userid," the last parameter in the command. A comment is entered that says "normal user." Userid's home directory will be "/home/userid." Userid's primary group will be users, but userid will also be placed in the "webadm" and "helpdesk" groups. Userid will use the "/bin/bash" shell as the normal console environment.

passwd [userid] - changes the users password

userdel -r userid - deletes a user ...the -r means to also delete the home directory

more /etc/passwd - allows you to view all the users and their associations - The first column contains the user name. The second column contains the user's password. The third column contains the user's numeric id. The fourth column contains the numeric id for the user's primary group. The fifth column contains the user's full name, or a comment. The sixth column contains the location of the user's home directory. Normally this directory lives in the /home directory and has the same name as the user id. The seventh column contains the user's default console shell.

groupadd mygroup - adds groups

ls -l - produces the following information relating to groups
-rw-r--r-- 1 userid mygroup 703 Jun 23 22:12 myfile

Ignoring the other columns for the moment, look at the third, fourth, and last columns. The third column contains the name of the owner of the file, userid. The fourth column contains the group associated with the file, mygroup. The last column is the file name. Each file can have only one owner and one group. It is possible to assign rights to Other, the users who don't fall into either category. Think of Other as the equivalent of the Windows group Everyone.

chown [owner] [file] - changes the owner of a file or directory

chmod [+-r+-w+-x] [file] - changes the permissions for a file

Network Mangement

ifconfig [ethernet port] - view current ethernet port configuration

ifup [eth port] - turn ethernet port on

ifdown [eth port]- turn ethernet port off

dhclient [ethernet port] - sets the ethernet port to dhcp and grabs IP

/sbin/service iptables stop - Linux firewall service stop

Crontab Management

crontab - allows you to work with items in the cron (task scheduler)
-l means list all cron jobs

Other often used commands

halt - to stop system

mount - to mount drives

umount [-f] (forces unmount) - to unmount drives

su - - root user with environment

ssh [-Y] (to port graphics)

nano - text editor

fsck - scans and defragments drive (perform at least once per month to not have it automatically kick in [that sucks])

rm -rf [directory]- removes directories with data inside

find - finds freggin anything

sleep [number of seconds] - very useful in scripts to make the system wait

man - manual it is your friend

less - displays a file page by page

Saturday, July 12, 2008

Lifecast Post Test

First post from my iTouch! I love the app store!

Posted with LifeCast

Wednesday, July 9, 2008

How to check what is running on your system

Ok if you have ever looked over the shoulder of a linux person goign to town you may have seen something like
ps -aux | grep cron

so here is what is really going on in that command

The ps command tells you what processes are actually running. In the manual it actual says that it gives you a snapshop of what is running on the system.

says print all processes owned by a user named "x" this could be changed to specify a specific user

The "|" or pipe symbol says to this command and this other command together

"grep" is a filter. If you were to simply type "ps" you woudl get a screen full of processes running for your user. By adding the "|" along with "grep" you can filter those processes down to what you need. In this case we looked for "cron" jobs (scheduled tasks). That can of course be changed to anything else you may need to check on.

So to say it all together the command
ps -aux | grep cron
is actually telling the computer to show all processes under any user that specifically deals with cron.

Hope that helps!!

Sunday, July 6, 2008

How to manually mount a USB Drive in Redhat

Inserting a USB storage device
  1. Plug in the device.
  2. Check the contents of the file /var/log/dmesg to see what the system named the device. (You can use the command dmesg as well.) It should appear as a SCSI device, so the name should be similar to /dev/sda or /dev/sdb.
  3. Use the command fdisk -l , replacing with the device name from /var/log/dmesg to determine the partitions on the device. Most USB flash drives and other portable storage media types have only one partition, so the output of the fdisk command will most likely be something like /dev/sda1 or /dev/sdb1.
  4. Create a directory (mkdir) to serve as the drive's mount point. It is recommended to use a name that is easy to remember like /mnt/usb.
  5. Mount the device with the mount command. If the device was detected as /dev/sda and the fdisk command showed /dev/sda1 as your partition, the command would be:
    mount /dev/sda1 /mnt/usb
    The mount command should automatically detect the partition type and mount the drive. It can be problematic to add the mount command to the file/etc/fstab, as the device may be detected with a different name if system devices are changed or if more than one USB device is plugged in at the same time. For this reason, it is recommended to mount the device manually with the full mount command listed above instead of relying on an entry in /etc/fstab.

Thursday, July 3, 2008

Geeky way to send a terminal message to a user

How to send someone a message over linux or unix

Step 1: Type who to find out what port they are on (the pts with the number is the port)
Step 2: cat >/dev/ptx/y
Step 3: type message
Step 4: press: "Ctrl + d" to end

***could also use the "write username [then optionally pts/terminal#]