Tag cloud

JBoss (16) Fedora (5) Linux (4) Red Hat (4) JON (3) command line (3) 4.3 (2) JEE (2) JVM (2) Java (2) KVM (2) Oracle (2) Portal (2) Weblogic (2) installation (2) vs (2) /boot partition (1) Add-ons (1) Apache (1) Bundles (1) Business model (1) Byteman (1) CLASSPATH (1) EAP (1) EPP (1) Eclipse (1) Failover (1) Gnome (1) JAVA_OPTS (1) JBDS (1) JBoss Tools (1) JBossON (1) JConsole (1) JDK (1) JMS (1) JVM options (1) KDE (1) MBean (1) Network (1) Open Source (1) RHQ (1) Red Hat subscription (1) Thunderbird (1) Troubleshooting (1) Virtulization (1) WS (1) Webservices (1) Wireshark (1) classloading (1) clustering (1) comparison (1) debug (1) deployment (1) disable SELinux (1) disksize (1) error (1) fun (1) jboss.org (1) log (1) log4j (1) lvm (1) messaging (1) multiple WARs (1) patent FOSS (1) performance tuning (1) provisionning (1) scripting (1) services (1) switch (1) troll (1) upgrade (1) video (1) war (1) webapp (1) yum (1)
Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

16 September 2010

Howto resize a partition

Command line:
[root]# df -m
[root]# lvm
(starts lvm command line)
Within lvm command line:
lvm> lvdisplay

-- resize swap to 1G
lvm> lvresize /dev/vg_f13v1/lv_swap --size 1G

-- after the operation your LV size is:( LV Size  1.00 GiB)
lvm> lvdisplay

--now add all remaining free space
lvresize -L +1.6GB /dev/vg_f13v1/lv_root

--trigger the resizing process
[root@f13-jon jon]# resize2fs -p /dev/vg_f13v1/lv_root

29 August 2010

Writing start scripts for services in Fedora linux

Howto manage your services and programs within Fedora

1. Make your shell script executable
All shell scripts in /usr/bin/ or /sbin/ can be executed anywhere within the command line
Add a softlink into /sbin or /usr/bin

$ cd /sbin
$ ln -s /app/jon/bin/rhq-server.sh jon
$ jon


1.5. Start your shell script at startup by modifying

Example:
$ sudo vi /etc/rc.d/rc.local
add:
killall -9 knetworkmanager & qdbus org.kde.kded /kded unloadModule networkmanagement && nm-applet &

2. Start your program easily via shell script
If you have a shell that takes the standard arguments : start / stop / restart
you can it into the repository /etc/init.d/.
All scripts in /etc/init.d/ can be called with
$ service my_script start
For convenience use a softlink instead of copying it into /etc/init.d:
$ cd /etc/init.d
$ ln -s /app/jon/bin/rhq-server.sh jon
$ service jon start

3. Service registry within Fedora (the startup services)
List all available services (/etc/init.d)
$ chkconfig --list
Start / stop the ssh daemon service
$ chkconfig sshd start (or stop)
Enable a service
$ chkconfig --add ssh
$ chkconfig sshd on
Disable a service
$ chkconfig sshd off
$ chkconfig sshd --del
If you you prefer a graphical interface for the service registry use
$ system-config-services


























4. Making an executable 'servicable'
Create a file in /etc/init.d, here an example: shutter 
#!/bin/sh
#
# shutter This script starts and stops the shutter daemon
#
# chkconfig: - 78 30
# processname: shutter
# description: shutter is a daemon process

get_shutter_pid () {
   SHUTTERPID=$( ps aux --cols 1024 | grep "perl" | grep "/usr/bin/shutter" | awk '{ print $2 }' | head -n 1 )
}

PIDFILE=/var/run/shutter.pid

# By default it's all good
RETVAL=0

BASE="/usr/bin"

# See how we were called.
case "$1" in
  start)
    # Start daemon.
    echo -n $"Starting shutter: "
    export DISPLAY=:0
    nohup ${BASE}/shutter > /dev/null &
        sleep 1
        get_shutter_pid
        echo -n ${SHUTTERPID} > ${PIDFILE}
        echo "Start Shutter : pid = ${SHUTTERPID}"
        ;;
  stop)
        # Stop daemons.
        get_shutter_pid
        if ! [ -z "${SHUTTERPID}" ] ; then
           echo "Stop Shutter : pid = ${SHUTTERPID}"
           kill "${SHUTTERPID}"
        fi
        ;;
  restart|force-reload)
        $0 stop
    sleep 8
        $0 start
        ;;
  status)
        get_shutter_pid
        if [ -z "${SHUTTERPID}" ] ; then
            echo "Shutter is stopped"
            exit 1
         else
            echo "Shutter (pid ${SHUTTERPID}) is being executed..."
            exit 0
         fi
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    RETVAL=1
    ;;
esac

exit $RETVAL

24 August 2010

My useful Linux commands

Some Linux commands I find useful:

Replace a string in all files recursively usind sed ( replaces repository.jboss.com with anonsvn.jboss.org/repos/repository.jboss.org)

grep -rl repository.jboss.com . | xargs sed -i 's/repository.jboss.com/anonsvn.jboss.org\/repos\/repository.jboss.org/'

Add launchers (*.desktop, icon - comment - name) here
/usr/share/applications


Find a file on the file system
updatedb
locate test.xml




Find out which kernel you are using
uname -r

Find string "proxy" in all files
sudo find . -type f -name "*" -exec grep -l "proxy" {} \;

find . -name "*" -exec grep "proxy" {} \;      (donne tous les lignes avec Test_1)
find . -name "*" -exec grep -l "proxy" {} \ ; (donne tous les fichiers avec Test)

grep -r 'proxy' *

Making a script executable
chmod +x

Finding all my files with string "myfile" including soft link references directories
find . -user me -name *myfile* -follow


Displaying directory structure
ls -rtl bbb (-R subdirectories)


Monitoring changes within a file
tail -100 fichier
tail -f file (monitoring)

grep -F ‘abc efg’ (Leerstelle = OR)
grep -i -n (line number) testChar file.txt

grep « VALOTRACE= » `(Alt + Shift + 7) find .`


cat fichier | grep blub
Displays full path of file being executed
which java

grep valopurgesolde.x communs/ces/x (pour voir qu’est-ce que le processus fait)
kill -9 -1 (killt das zuletzt angemeldete Konto)
cd - (go to root)
du -sk . (Wie viel Speicherplatz belegt)
df -k (kilo) . (combien il reste sur le filesystem)
ps -u valqua11  (kill -9 #1 #2)

ln -s link name (ln -s ${HOME}/brackmann roli)
Displaying all exports of the shell
typeset
Process keeps on running in background even when the executing shell is killed
nohup your_command


Gets the 4th columns of the server.log and deletes all the doubles


cat server.log | awk '{ print $4; }' | sort -u > server4thcolumndistinct.log


Deletes all temporary files followed by '~'
find ./ -name '*~' | xargs rm