Tuesday 14th of May 2024 08:26:34 PM

home

workflow notes dbconsole dbnotes Linux ULN vi cookbook

 

Linux System Configs

logical volume manager (lvm)

Unix

kill process mail screen reboot Linux rpm pkg Up2Date
delete stuff   mount fs crontab Change Hostname VeritasAgent
change shell alias root email mount usb add a pkg lost root password ramspeed and type
inodes maillog mount dvd add a menu StartAServiceAtStartup X11R6/bin/xdpyinfo
useradd mount NTFS drive Change UID Firewall gui ChangeSshdPort
    SecureLinuxLogin     Console Apps
NFS server   cowsay uuencode script to logeverything

 

NFS
Enabling and Starting NFS Server

If you must use NFS, it can be activated using the following commands on Red Hat Linux:
    
    chkconfig portmap on  
    chkconfig nfs on  
    service portmap start  
    service nfs start  
    

 

Determine the available RAM and swap space:

# free

Determine the RAM size:

grep MemTotal /proc/meminfo

Determine the amount of free disk space available in the /tmp directory

# df -k /tmp or df -H /tmp

Determine the size of the configured swap space:

# grep SwapTotal /proc/meminfo

Delete a bunch of files at once

find . -name '*.log' \! -mtime -10 -exec rm {} \;

Delete files by inodes. Use this if just by chance you accidently created a file with a name like * , which would delete everything in the directory if you tried to delete it with rm * instead of just deleting the file named "*" or whatever other dumb name you named the file you want to remove. Don't even ask, I've never created a file with a dumb name.

cd to the directory where the file resides

list the inode of the file you want to delete

ls -i

or

ls -ltrai

137003011 -rw-r--r-- 1 root root 3558 Aug 11 2009 install.log.syslog
137003010 -rw-r--r-- 1 root root 36482 Aug 11 2009 install.log
137003017 -rw------- 1 root root 1561 Aug 11 2009 anaconda-ks.cfg
137003024 drwxr-xr-x 3 root root 4096 Aug 26 2009 oradiag_root
49053839 -rw------- 1 root root 679795 Sep 1 2009 mbox

{ remove the file by the inode}

find . -inum 137003011 -exec rm {} \;
Rename the file to a normal name instead of removing it if you're uncomfortable deleting the funky named file 
You can then  delete the renamed file. The new file name in this case is named "newname" 
% find . -inum 137003011 -exec mv {} newname \;

find a file by something inside the file

find . type f -print | xargs grep -li whateveryouwanttosearchfor

find a file by file type and name , then send the junk output to nowhere so it won't clog up your screen

find / -type d -name "Updates" -print 2>/dev/null

Kill multiple processes at once

ps -ef|grep oratst |grep "LOCAL=NO" |awk '{ print $2 }' |xargs kill -9

 

Control M out of a file

If you want to remove the ^M characters, you can use dos2unix

'/usr/bin/dos2unix'

dos2unix a.txt b.txt

or tr

 

tr -d '\r' < infile.txt > outfile.

 

 

Set Line #'s in a vi'd file

set number
set nonumber

process Id variable

$$

http://tldp.org/LDP/abs/html/internalvariables.html

Change a users login shell

http://www.debian-administration.org/articles/231

If you're root you can change the shell for a user by adding the username to the command line:

root@mystery:~# chsh skx

You can also supply the shell name without being prompted for it interactively with the -s argument:

root@mystery:~# chsh -s /bin/zsh skx
skx@mystery:~$ chsh  -s /bin/bash  
Password: 

 

The correct way for a user to change his or her shell is via the   chsh command.
chsh stands for change shell, and does exactly what the name suggests.
Invoke it with no arguments and you will be prompted for your password, then you will be prompted 
for your shell.
The file /etc/shells is consulted, and your chosen shell must be included in there for your change 
to be accepted. If you enter the name of a binary which is not contained in /etc/shells you'll 
receive and error similar to this:
skx@mystery:~$ chsh 
Password:   
Changing the login shell for skx  
Enter the new value, or press return for the default          
Login Shell [/bin/sh]: /bin/fff  
/bin/fff is an invalid shell. 

remove a package from linux

remove rpm

Tried to install

rpm -ivh glibc-2.5-49.i686.rpm

This errored with conflicts:

part of the error:

file /usr/share/i18n/charmaps/WINDOWS-31J.gz from install of glibc-common-2.5-49.x86_64 conflicts with file from package glibc-common-2.5-49.el5_5.7.x86_64

rpm -e glibc-common-2.5-49.el5_5.7.x86_64
error: Failed dependencies:
glibc-common = 2.5-49el5_5.7 is needed by (installed) glibc-2.5-49.el5_5.7.x86_64
glibc-common = 2.5-49.el5_5.7 is needed by (installed) glibc-2.5-49.el5_5.7.i686
/usr/bin/gencat is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.x86_64
/usr/bin/gencat is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.i386
/usr/bin/getconf is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.x86_64
/usr/bin/getconf is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.i386
/usr/bin/iconv is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.x86_64
/usr/bin/iconv is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.i386
/usr/bin/locale is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.x86_64
/usr/bin/locale is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.i386
/usr/bin/localedef is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.x86_64
/usr/bin/localedef is needed by (installed) redhat-lsb-3.1-12.3.EL.0.2.i386

 

Use this to remove the file with conflicts:

rpm -e --nodeps glibc-common-2.5-49.el5_5.7.x86_64

 

 


check if something's installed on Linux

rpm -aq |grep snmp

rpm -aq |grep telnet

install a package:

rpm -ivh

up2date package - rpm

rpm -qa |grep up2date

rpm -qa|grep yum

rpm -qa --queryformat "|%{NAME}|%{VERSION}|%{RELEASE}|%{ARCH}|\n" | grep compat-db

rpm -qa --queryformat "|%{NAME}|%{VERSION}|%{RELEASE}|%{ARCH}|\n" | grep <packageName>


 
confirm libXp.so.6
rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" | grep libXp
 


test the mailserver


telnet 127.0.0.1 
to escape: 
^]

telnet>quit


nslookup earth.moon.com

ping earth.moon.com

traceroute earth.moon.com


Send a test message. There is a "." after data

telnet earth.moon.com 25

helo earth.moon.com

MAIL FROM: venus@earth.moon.com

RCPT TO: zeus@earth.moon.com

DATA

.

 

Check Mail Logs

tail -f /var/log/maillog

grep something /var/log/maillog

how to mount NTFS harddrive on OEL Linux

 

 

Setup nfs mount to copy patches and disks from one server to another.

Add this directory to the NFS exports file /etc/exports
/oraclenfs *(rw,sync,all_squash,anonuid=500,anongid=500)

vi /etc/exports

<directory you want to share> <server you want to share it with><permissions you want to use> Don't add a space between the permissions and the server

/u09 earth(rw) venus(rw) pluto(rw)
/u10 earth(rw) venus(rw) pluto(rw)
/data earth(rw) venus(rw) pluto(rw)

 

service nfs stop
service nfs start

From earth:

Mount pluto:/u09 /data/mo

From Venus

mount earth:/u09 /data/lmu

Check if the oraclefs directory is exported correctly by issuing the exportfs –v command.

exportfs -a

rpcinfo -p <servername>

Unable to umount an nfs file system. First check that you are not in the directory. This is the usual cause. Check if you have an open screen that is holding the directory. Use lsof if you have to. If you can't find anything holding it. (you have something , your probably in it.) You can force it to umount.

a lazy unmount:
umount -l /mnt/deadmount

(run as root):

# umount tmpfs  
# mount -t tmpfs shmfs -o size=1300m /dev/shm  

# df -k /dev/shm  
Filesystem    1K-blocks  Used Available Use% Mounted on  
                  shmfs         1331200      0   1331200   0% /dev/shm
Did this instead:

mount -t tmpfs -o size=2071016 tmpfs /dev/shm



http://blog.tanelpoder.com/2007/08/21/oracle-11g-internals-part-1-automatic-memory-management/

http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html
This didn't work for me...
For example, if you have 8GB RAM then remount /dev/shm as follows:
   #   mount -o remount,size=8G /dev/shm
   To be frank, if you have more than 2GB RAM + multiple Virtual machines, 
   this hack always improves performance.
# mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs   /disk2/tmpfs

The above will give you tmpfs instance on /disk2/tmpfs which can allocate 5GB RAM/SWAP in 5K inodes and it is only accessible by root.

How to umount when the device is busy

# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

syslog-logwatch

/etc/cron.daily

0anacron cups makewhatis.cron prelink tmpwatch
0logwatch logrotate mlocate.cron rpm

0logwatch -> /usr/share/logwatch/scripts/logwatch.pl

adadmin logs:

/u02/oracle/TEST/apps/apps_st/appl/admin/TEST/log/adamin_120109.log

start stop sendmail

service sendmail stop

/etc/init.d/sendmail stop
/etc/init.d/sendmail start
/etc/init.d/sendmail restart

Forward root email

   /etc/aliases 
   add the Person who should get root email

Rebuild alias database (after aliasing root email to another user)

# newaliases

Mail a file from Linux

mailx monique9@gmail.com < <filename> (this mails the file in the body of the email)

To mail the file as an attachment use uuencode

In Red Hat Linux, uuencode is part of the sharutils package. You'll have to add it. It's not installed by default.

rpm -ivh sharutils-4.6.1-2.x86_64.rpm (this is the package on OEL 5.3)

uuencode file file.name | mailx email@address
uuencode input_file output_file | sendmail   recipient(s)
uuencode input_file output_file | mail -s subject recipient(s)

uuencode input_file output_file | mailx -s subject recipient(s)
cat ${SUC_Template}.${DATE_TIME}.$$.tmp;uuencode ${ZIPFILE} "${SQL_NAME}.zp") | mailx -n -s "${SUBJECT}" ${BizEMailAddr} If change the mailx switch "-n" to "-m" it works. (cat $tmpbody; uuencode $filename $filename) | mail -s "${subject}" $location

how to send MIME attachments on the command-line mail client

uuencode -m input_file output_file | mail -s mail_subject recipient(s)

If you want to use ESC-K to see history:

ksh  –o vi

send something to nowhere:

2>/dev/null

VI

If you want to enter joe in the beginning of each line:

:%s/^/joe/

If you want a space after joe ":%s/^/Joe /"

:%s/^/joe /

install a package:

rpm -ivh <package name>

check if a package is installed:

rpm -q <package name>

Change username from tom to jerry

Type usermod command as follows:
# id tom
# usermod -l jerry tom
# id jerry
# id tom

Change user tom UID from 5001 to 10000

Type usermod command as follows
# id tom
# usermod -u 10000 tom
# id tom

Change the hostname

http://nixcraft.com/getting-started-tutorials/823-redhat-enterprise-linux-rhel-start-service-boot.html

ntsysv - simple TUI (text based interface) interface for configuring runlevels.

chkconfig - chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories

Turn on sshd service on boot

chkconfig sshd on

Turn on Apache / httpd service on boot

chkconfig httpd on

List if service is on or off on boot

/sbin/chkconfig --list

 

Crontab

http://www.unix.com/answers-frequently-asked-questions/13527-cron-crontab.html

Edit your crontab

crontab -l > mycrontab

vi mycrontab


crontab < mycrontab

Copy your crontab to a file

edit the file and make your changes

update crontab with your changes

 



crontab
1. Crontab Restrictions
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

2. Crontab Commands

export EDITOR=vi ;to specify a editor to open crontab file.

crontab -e    Edit your crontab file, or create one if it doesn’t already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.(don't do this)
crontab -v      Display the last time you edited your crontab file. (This option is only available on a few systems.)

After editing the file, save it with cntrl-c





*     *     *   *    *        <command to be executed> 
-     -     -   -    -  
|     |     |   |    |  
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)  
|     |     |   +------- month (1 - 12)  
|     |     +--------- day of month (1 - 31)  
|     +----------- hour (0 - 23)  
+------------- min (0 - 59)  



      

. Crontab Example
A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.

30     18     *     *     *         rm /home/someuser/tmp/*

Crontab Environment
cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user’s-home-directory
LOGNAME=user’s-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.

6. Disable Email
By default cron jobs sends a email to the user account executing the cronjob. If this is not neededput the following command At the end of the cron job line .

>/dev/null 2>&1

7. Generate log file
To collect the cron execution execution log in a file :

30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

How Many Inodes are there?
df's -i option instructs it to supply information about inodes on each filesystem rather than about available space. Specifically, it tells df to return for each mounted filesystem the total number of inodes, the number of free inodes, the number of used inodes and the percentage of inodes used. This option can be used together with the -h option as follows to make the output easier to read:
df -hi

 

Check RAM Speed and Type

sudo dmidecode --type 17

or$ sudo dmidecode --type 17 | more

 

or dmidecode > code.txt - then check the text file for info

 

type 17:

Handle 0x000D, DMI type 17, 27 bytes.
Memory Device
Array Handle: 0x0009
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: DIMM
Set: None
Locator: DIMM02
Bank Locator: BANK02
Type: Other
Type Detail: Unknown
Speed: 800 MHz (1.2 ns)
Manufacturer: Micron
Serial Number: B25D58D8
Asset Tag: Unknown
Part Number: 36JSZF51272PY1G4D1

 

 

SCREEN:

Provide ANSI/VT100 terminal emulation, making it possible to run
multiple full-screen pseudo-terminals from one real terminal, and
letting you manipulate and save your screen input and output, copy
and paste between windows, etc.

http://www.oreillynet.com/linux/cmd/cmd.csp?path=s/screen

screen location: Screen is located on the Linux DVD under /Server

copy screen program to /data on earth
rpm ivh screen-4.0.3-1.el5.x86_64.rpm

Using Screen:
[root@earth Server]# screen
To open a new window, you just use “Ctrl-A” “c”.

To get back to top, use “Ctrl-A “n”

1. You kill the window with “Ctrl-A” “K” or “exit” will work on some systems. This will kill the current windows.
If you have other windows, you will drop into one of those. If this is the last window, then you will exit screen.

2. The second way to leave screen is to detach from a windows. This method leaves the process running and simply closes the window.
If you have really long processes, you need to close your SSH program, you can detach from the window using “Ctrl-A” “d”.
This will drop you into your shell. All screen windows are still there and you can re-attach to them later

3. Reattach to screen. Find the screens that are open:

screen -ls

To reattach to a screen with the -r flag and the session name.

screen -r <session from ls>

Using “Ctrl-A” “H”, creates a running log of the session

If Screen is attached elsewhere, holding an nsf mounted file system or some other random annoying thing. Your not able to attach to it., because it's attached to nothing.This is the long way if you don't know how to get rid of it, this will.

screen -ls -list out the screen
screen -D <screen-listed> will detach the attached screen
screen -r <screen-listed> will attach to the detatched screen
exit - will exit out of the screen  

-D

Detach session running elsewhere, logging out before detaching.With -r,
reattach to this terminal. With -R, reattach to this terminal or create
it if it doesn't already exist. With -RR, do whatever is necessary to
create a new session.

How to connect to another user's console using screen:

http://ubuntuforums.org/showthread.php?t=299286

http://www.linuxquestions.org/questions/linux-general-1/problem-using-screen-cannot-open-your-terminal-dev-pts-0-please-check-338313/

Could not execute auto check for display colors using command /usr/X11R6/bin/xdpyinfo. Check if the DISPLAY variable is set."
Locate the utility on your system by typing:         
locate xdpyinfo
Once the location is determined, create a link to the correct location:
        
ln -s <actual path   to file>/xdpyinfo <expected path to file>/xdpyinfo
i.e
        
 ln -s   /usr/bin/xdpyinfo /usr/X11R6/bin/xdpyinfo

 


 

 

Logwatch

http://www.stellarcore.net/logwatch/tabs/docs/HOWTO-Customize-LogWatch.html

usr/share/logwatch

 

 

Console Apps

system-config-securitylevel - opens the firewall console apps

the apps you can open with the console are listed in /etc/security/console.apps

Here is what in my /etc/security/console.apps

system-cdinstall-helper system-config-lvm system-config-time
system-config-authentication system-config-netboot system-config-users
system-config-date system-config-network system-install-packages
system-config-display system-config-network-cmd system-config-selinux
system-config-kdump system-config-printer system-config-services
system-config-keyboard system-config-rootpassword system-config-soundcard
system-config-language system-config-securitylevel

this too:

 

authconfig neat sabayon
authconfig-gtk pirut serviceconf
authconfig-tui pm-hibernate setup
cpufreq-selector pm-powersave up2date
dateconfig pm-suspend up2date-config
eject pm-suspend-hybrid up2date-nox
gdmsetup poweroff xserver
gnome-system-log pup
halt reboot
kbdrate rhn_register

 

Cowsay
http://www.nog.net/~tony/warez/cowsay.shtml

 

 

home

© 2007-2024 LMU. All rights reserved.