Linux
Linux is for intelligent people.
Applying updates normally blocked
RHEL4:
$ sudo up2date --list $ sudo up2date --update --force
RHEL5:
$ sudo yum check-update $ sudo yum upgrade
Search for an application
$ yum search fooapp $ yum list fooapp $ rpm -qa | grep -i foo
Remove an rpm package
$ sudo yum remove package_name
Miscellaneous Linux Tech Notes
- For keyword specific options (e.g. binding a MAC address to a specific eth port see: http://www.linux.ncsu.edu/moin/RealmLinuxServers/Configuring_Static_and_...
- Whenever a machine's IP is moved on QIP type: ncsubless Make sure to enter the fqdn on the /etc/hosts & /etc/configsys/network files
- To find out about what version of linux are we running and other CPU specs:
more /proc/version
more /proc/cpuinfo
more /proc/meminfo
cat /etc/redhat-release - To schedule shutdown of a redhat box: /sbin/shutdown -h hh:mm
- uname reports the running kernel.
- rpm -qa kernel\* will show you what's installed
- netstat -antp (to see open connections)
- To setup a service to automatically start at bootup: /sbin/chkconfig --level 2345 servicename on (where servicename must exist under /etc/init.d/)
- For example /sbin/chkconfig --list sendmail (displays runlevels that sendmail is set to run on)
- To check current RAID configuration: cat /proc/mdstat also used the /sbin/fdisk -l command to get more info. To learn more about RAID configuration check http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_L...
More Linux Commands
Useful Commands for Mac OS X and Linux
$ ls (insert any letters) TAB (hit TAB twice in Linux)
-will give you the files in the current directory that begin with (letters)
$ file file_name-this will return what kind of file the name file is
$ less file_name-less lets your scroll back up when viewing a file
$ ls -l | more
-the pipe command will string things together, in this case it uses the "more" command on the output of ls -l
$ man command_name
-gives description of command
$ info command_name
-more info than man command
$ apropos command_name
-gives all man pages for commands that might help with understanding command_name
$ touch -t 05070915 my_report.txt
-Used to change the date and time of a file. The first four digits stand for May 7 (0507) and the last four (0915) the time, 9:15 in the morning
$ find -name OR -mmin+0 -mmin -10
-the find command can be used to find files by name or age (this example does files in the last ten minutes)
$ grep
-grep is used to find words in files
$ who
-who is used to find out who is working on your system
$ whoami
-tells you which user you are
$ whatis
-explain the use of a command
$ whereis
-location of a command
$ date
-gives the date
$ last
-who logged into the machine recently
$ df
-how much disk space is used
$ du
-how large is a file
$ top
-see what processes are running on your machine (and percentage of CPU usage for each
$ ps
-see list of process running on the machine, descriptive
$ kill
-use kill in association with a PID to stop a process
$mount -t /dev/fd0 /floppy
-mounts a floppy
-t expresses the system type
-/dev/fd0 picks the hardware file to mount
-/floppy tells where to mount it
$ mount -t iso9660 /dev/hdb /cdrom
-mounts a CDROM
-iso9660 is a standard CD file structre
$ mount -t /dev/hda1 /mnt
-mounts another partition on the harddrive
$ umount /mounted_drive_name
-unmounts specified drive
$ tar -cvf tarfile_name.tar files_to_tar
-files to tar = *.txt, mary*.txt
-c is for create
-v verbose (show what files are)
-f make a file (f should always be last)
-z will compress the file as well; be sure to the name the file ".tar.gz" (see more info below on gzip)
$ tar -zxvpf
-this is used to unzip the file
-x used to extract the tar files
-p used to keep file permissions, dates, info, etc. about the tarred files
$ gzip your_tar_file.tar
-tar does NOT compress files, use gzip to compress your tar files
$ rm -fR /file_name
-this will remove a directory and everything below it
$ ln -s /source /destination
-create a sim link to files in other places
$ hdiutil makehybrid –iso -o outputfile.iso source
-create an iso file from source
$ bc
-built in simple calculator
$ sudo !!
-run sudo in front of the last command run
$ sh command.sh
-run a shell command in Mac OS X
$ open .ssh
-takes you to known_hosts file
$ chown -R username /filename
-changes the owner of /filename to /username
$ ifconfig eth0 inet 192.168.1.100
-sets ip address to 192.168.1.100
$ ifconfig eth0 netmask 255.255.255.0
-sets ip netmask
$ date “+%Y_%m_%d”
-displays date in format: yyyy_mm_dd
$ mkdir *
$( command here)
-you can run a command to be the argument of another command by starting another shell *
$ telnet IP/hostname port#
-you can check to see if a port is open on a machine using this
$ scp /path/file user@server.domain.com:/path/
-use this to run file transfer over ssh
-specify –r to copy an entire folder and all of it’s contents