WaZaRWiki : LinuxTips

GaelReignier :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register :: Hosted by: eNiX
ITTips


General tips

getent: then use passwd or ldap for checking the users in those files

During the startup of a CentOS, you can hit the i key to enter the interactive mode and choose which module to load.

pstree: to show the dependences of a process

sed -e "regexp" i.e.: sed -e s/blah/boup/g = sed -e s,blah,bloup,g This is useful when you are scripting and using variables containing path as you cannot do \/ in the variable ...

awk '{print $1}'

Using less then press Shift+F will do the equivalent as tail -f with the advantages of less

When a process is in an interruptable sleep, you do not have any other choice than restarting the box to get rid of it.

Number of maximum open files: cat /proc/sys/fs/file-max

/etc/sysctl.conf : to tweak the kernel at startup

sysctl -A: displays the runtime kernel parameters.

Fosco Tips: grep -rH 'You are now configured to use the Fleet St HQ' /etc/

rsync and ssh on another port than port 22:
rsync -av --progress --inplace --rsh='ssh -p8023' somefile user@host:somedir/


Switch User
su - user -c 'command': this allows you to run a command while changing user.

SCREEN
CTRL+AC: creates a new screen in a screen session
CTRL+Aspace key: Move to the screen on the right
CTRL+Areturn key: Move to the screen on the left
CTRL+AA: move between the 2 last accessed screen
CTRL+A shift+A: Change the name of a screen window

When running screen sometimes there is a problem using the backspace or delete key and you get the dreaded “Wuff Wuff” message.
Edit: ~/.bashrc
And add:
alias screen='TERM=screen screen'

Status line:
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %Y-%m-%d %{W}%c %{g}]"


hardstatus alwayslastline
 hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %Y-%m-%d %{W}%c %{g}]"


In ~/.screenrc
multiuser on
acladd jose,serkan


In case of a message like:

Must run suid root for multiuser support.

Do


First of all, in screen you have to hit C^a and then the colon (":") key to enter commands (much like vi). when you do that, you'll see a highlighted colon prompt at the bottom of the screen. Then turn on multiuser and grant permissions like Sanjay said.

Second, you may have to do some other things. I installed screen with the Debian package, and multiuser mode didn't work out of the box. You could add people to the acl list, but when you did:
screen -ls otheruser/
you'd get the error:
Must run suid root for multiuser support.

To make screen run as suid root, as the root user do:
chmod +s /usr/bin/screen
(or whatever the path to your screen executable is)

There is also a command called aclgrp, whereby you can assigna group of users similar access to screen. Note that this doesn't mean you can automatically give everyone in a particular Unix group access to a screen session, though. I might work on a little script to do that. If I figure it out, I'll post it here.

You have to
chmod 755 /var/run/screen/

More information on this web page: http://www.softpanorama.org/Utilities/screen.shtml

CentOS specific

chkconfig --list: will display which service are started in the different run levels
chkconfig servicename on/off: starts the servicename in appropriate runlevel

Check library dependency
ldd executable_file

Reload .bash_profile
source .bash_profile

Change display color setting for a shell
dircolors

Startup message
/etc/motd
/etc/profile

VIM
This is a really nice bit of information: http://www.vim.org/tips/tip.php?tip_id=305

Doing some tricks on a all set of lines:
Syntax highlighting: :syntax enable
The g command explanation: http://www.vim.org/tips/tip.php?tip_id=227

useful command for stopping indentation when pasting: set paste

To get some help for ctrl+w for instance: :h CTRL-W

My .vimrc file:
syntax on
set nu
set hlsearch
set incsearch
set autoindent


To search a pattern across an entire file, go onto the work and press the start "*" key.

LVM

Extend a partition:
1. lvextend -L+5G /dev/vg_data/Movies
2. resize2fs /dev/vg_data/Movies

LVM overhead:

GA_L: z00dax6: because of the LVM overhead
(08:40:37 PM) z00dax6: GA_L: how much is it ?
(08:41:05 PM) GA_L: z00dax6: never quantified it just gut feeling and what I read on the web
(08:41:17 PM) z00dax6: its about 2.6% per layer
...
(08:45:25 PM) GA_L: z00dax6: how do you know about the 2.6%?
(08:46:02 PM) z00dax6: measured it, many times in various situations.
(08:46:09 PM) z00dax6: it varries between 1.8% to 5%
(08:46:29 PM) z00dax6: 2.6% is my ballpark though :)

Add a disk to a Volume group: complete source: http://sujithemmanuel.blogspot.com/2007/04/how-to-add-disk-to-lvm.html
77 fdisk /dev/xvdb
78 mkfs -t ext3 /dev/xvdb1
79 pvcreate /dev/xvdb1
80 pvscan
81 vgextend VolGroup00 /dev/xvdb1
82 pvscan
83 vgscan
84 df -h
85 vgdisplay -v VolGroup00
86 df -h
87 lvextend -L+10G /dev/VolGroup00/vg00root
88 resize2fs /dev/VolGroup00/vg00root
89 pvscan
90 lvextend -L+10G /dev/VolGroup00/vgvar
91 resize2fs /dev/VolGroup00/vgvar
92 lvextend -L+10G /dev/VolGroup00/vgvar
93 resize2fs /dev/VolGroup00/vgvar
94 df -h
95 lvextend -L+5G /dev/VolGroup00/vghome
96 resize2fs /dev/VolGroup00/vghome


Channel bonding

# cat /etc/modprobe.d/bonding.local

alias bond0 bonding
options bonding miimon=100 mode=balance-rr

http://smhteam.info/wiki/index.linux.php5?wiki=ChannelBonding

SSL


Generate a new private key: openssl genrsa -des3 -out domain.name.key 1024
Generate a CSR: openssl req -new -key domain.name.key -out domain.name.csr

digicert is good

tar

tar -cvvf destination.tar source


email redirection

Update the file /etc/aliases and add the email address you want the email sent to as follow:
 root:           gael@coincoin.com


Then run the command:
newaliases



tcpdump

To get any TCP traffic on port 3306
tcpdump -pni any tcp port 3306


To get any traffic from 10.10.5.6 on eth0
tcpdump -pni eth0 src 10.10.5.6


In order to see what is happening multicast-wise.
tcpdump -n ether multicast

time

symlink /etc/localtime pointing to your time zone change it to link to GMT in /usr/share/zoneinfo


Add repository


RPMforge: http://wiki.centos.org/AdditionalResources/Repositories/RPMForge?action=show&redirect=Repositories%2FRPMForge

Memory Management


There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0264 seconds