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@192.168.254.108:/mnt/storage/20080717A /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)

example:
autossh -M 20000 -N -R 11000:localhost:22 jpowell@ssh.cresis.ku.edu -p 62

person ssh in to this would use:
ssh -p 11000 localhost (this is assuming they are on ssh.cresis.ku.edu)


dd command options

dd -fi=input directory -do=file out




Managing users and permissions

useradd - used to add users
syntax:
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

No comments: