Sign up to create your own snipts, or login.

Public snipts » unix The latest public unix snipts.

showing 1-20 of 79 snipts for unix
  • install Drush from CVS HEAD on any unix server
    ##
    ## Installs Drush (the Drupal Shell command line utility) from CVS HEAD 
    ## on any UNIX machine, such that all users that have /usr/local/bin in
    ## their $PATH can use Drush (granted they have access to a Drupal install).
    ##
    ##
    
    cd /usr/local/src
    cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d drush-HEAD contributions/modules/drush/
    curl -O http://download.pear.php.net/package/Console_Table-1.1.3.tgz
    tar zxvf Console_Table-1.1.3.tgz
    cp Console_Table-1.1.3/Table.php drush-HEAD/includes/table.inc
    ln -s /usr/local/src/drush-HEAD/drush /usr/local/bin/drush
    
    ##
    ## now any user that has /usr/local/bin in their $PATH can use Drush.
    ##
    ##
    ## ... later on, to keep drush up to date, run the following:
    
    #cd /usr/local/src/drush-HEAD
    #cvs update -dPA
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Mar 05, 2010 at 11:38 a.m. EST
  • find and delete
    find . -name "FILE-TO-FIND"-exec rm -rf {} \;
    

    copy | embed

    0 comments - tagged in  posted by mccu7pj2 on Mar 02, 2010 at 10:51 a.m. EST
  • Showing Unix System listening ports
    $ netstat -ntlup
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
    tcp        0      0 0.0.0.0:20000               0.0.0.0:*                   LISTEN      28946/perl          
    tcp        0      0 0.0.0.0:2273                0.0.0.0:*                   LISTEN      28855/mysqlmanager  
    tcp        0      0 0.0.0.0:199                 0.0.0.0:*                   LISTEN      28193/snmpd         
    tcp        0      0 127.0.0.1:10025             0.0.0.0:*                   LISTEN      22267/amavisd (mast 
    tcp        0      0 172.26.0.5:3306             0.0.0.0:*                   LISTEN      30760/mysqld        
    tcp        0      0 127.0.0.1:10026             0.0.0.0:*                   LISTEN      22389/smtpd         
    tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN      28352/smbd          
    tcp        0      0 127.0.0.1:3310              0.0.0.0:*                   LISTEN      28420/lt-clamd      
    tcp        0      0 127.0.0.1:10030             0.0.0.0:*                   LISTEN      28242/postgrey -d - 
    tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      23007/pop3-login    
    tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN      22298/perl          
    tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      28148/dovecot       
    tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      802/httpd           
    tcp        0      0 172.26.0.5:80               0.0.0.0:*                   LISTEN      802/httpd           
    tcp        0      0 127.0.0.1:8118              0.0.0.0:*                   LISTEN      28269/privoxy       
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      28199/sshd          
    tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      22339/smtpd         
    tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      28320/perl          
    tcp        0      0 0.0.0.0:445                 0.0.0.0:*                   LISTEN      28352/smbd          
    tcp        0      0 :::22                       :::*                        LISTEN      28199/sshd          
    udp        0      0 172.26.0.5:137              0.0.0.0:*                               28361/nmbd          
    udp        0      0 0.0.0.0:137                 0.0.0.0:*                               28361/nmbd          
    udp        0      0 172.26.0.5:138              0.0.0.0:*                               28361/nmbd          
    udp        0      0 0.0.0.0:138                 0.0.0.0:*                               28361/nmbd          
    udp        0      0 0.0.0.0:10000               0.0.0.0:*                               28320/perl          
    udp        0      0 0.0.0.0:20000               0.0.0.0:*                               28946/perl          
    udp        0      0 0.0.0.0:161                 0.0.0.0:*                               28193/snmpd         
    udp        0      0 0.0.0.0:53455               0.0.0.0:*                               27475/avahi-daemon: 
    udp        0      0 0.0.0.0:5353                0.0.0.0:*                               27475/avahi-daemon: 
    udp        0      0 172.26.0.5:123              0.0.0.0:*                               28787/ntpd          
    udp        0      0 127.0.0.1:123               0.0.0.0:*                               28787/ntpd          
    udp        0      0 0.0.0.0:123                 0.0.0.0:*                               28787/ntpd          
    udp        0      0 fe80::21e:90ff:fe29:123     :::*                                    28787/ntpd          
    udp        0      0 ::1:123                     :::*                                    28787/ntpd          
    udp        0      0 :::123                      :::*                                    28787/ntpd 
    

    copy | embed

    0 comments - tagged in  posted by yvoictra on Jan 17, 2010 at 8:38 a.m. EST
  • List subdirectories of curren directory.
    #include <dirent.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <errno.h>
    #include <sys/stat.h>
    
    int main(int argc, char *argv[])
    {
    	DIR *d;
    	struct dirent *de;
    
    	d = opendir(".");
    	if (!d) {
    		perror("opening current directory");
    		exit(1);
    	}
    
    	errno = 0;
    	for (;;) {
    		de = readdir(d);
    		if (de == NULL)
    			break;
    		struct stat file_info;
    		memset(&file_info, 0, sizeof (file_info));
    		if (de->d_name[0] == '.')
    			continue;
    		if (stat(de->d_name, &file_info) == 0) {
    			if ((file_info.st_mode & S_IFMT) == S_IFDIR) {
    				printf("%s\n", de->d_name);
    			}
    		} else {
    			printf("stat() error %s on file %s\n",
    				strerror(errno), de->d_name);
    		}
    	}
    
    	if (errno != 0)
    		perror("reading directory");
    
    	closedir(d);
    	return 0;
    }
    

    copy | embed

    0 comments - tagged in  posted by marcbutler on Dec 25, 2009 at 12:17 a.m. EST
  • Shell script to read local IP address (works on GNU/Linux, *BSD and Solaris)
    #!/bin/sh
    # Shell script to read IP address
    # -------------------------------------------------------------------------
    # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
    # This script is licensed under GNU GPL version 2.0 or above
    # -------------------------------------------------------------------------
    # This script is part of nixCraft shell script collection (NSSC)
    # Visit http://bash.cyberciti.biz/ for more information.
    # -------------------------------------------------------------------------
    # Get OS name
    
    OS=`uname`
    IO="" # store IP
    case $OS in
       Linux) IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;;
       FreeBSD|OpenBSD) IP=`ifconfig  | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'` ;;
       SunOS) IP=`ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{ print $2} '` ;;
       *) IP="Unknown";;
    esac
    echo "$IP"
    

    copy | embed

    0 comments - tagged in  posted by d1s4st3r on Dec 03, 2009 at 3:27 a.m. EST
  • forget the crontab man
    #minute (0-59),
    #|      hour (0-23),
    #|      |       day of the month (1-31),
    #|      |       |       month of the year (1-12),
    #|      |       |       |       day of the week (0-6 with 0=Sunday).
    #|      |       |       |       |       commands
    0       2       *       *       0,4     /etc/cron.d/logchecker
    

    copy | embed

    1 comment - tagged in  posted by juque on Nov 11, 2009 at 6:57 a.m. EST
  • check folder size
    % du -hs /path/to/directory
    

    copy | embed

    0 comments - tagged in  posted by chawei on Nov 04, 2009 at 8:45 a.m. EST
  • linux permission
    # permission
    useradd new-user
    chown new-user somefile
    
    groupadd new-group
    chgrp new-group somefile
    
    % chown user file
    % chown :group file
    % chown user:group file
    % chown -fR user:group file
    

    copy | embed

    0 comments - tagged in  posted by chawei on Oct 17, 2009 at 1:28 p.m. EDT
  • List Todays Modified Files
    find . -mtime -1 -type f -exec ls -lt {} \;
    

    copy | embed

    1 comment - tagged in  posted by elaforc on Sep 28, 2009 at 9:57 a.m. EDT
  • size of directories
    du -h —max-depth=1
    

    copy | embed

    0 comments - tagged in  posted by sevitzdotcom on Sep 26, 2009 at 7:27 a.m. EDT
  • file system usage
    df -h
    

    copy | embed

    0 comments - tagged in  posted by sevitzdotcom on Sep 26, 2009 at 7:26 a.m. EDT
  • check fcgi
    ps aux | grep fcgi
    

    copy | embed

    0 comments - tagged in  posted by chawei on Aug 28, 2009 at 9:03 a.m. EDT
  • disable Spotlight
    // disable spotlight indexing
    
    sudo mdutil -i off  
    
    // enable spotlight indexing
    
    sudo mdutil -i on
    
    // delete existing spotlight indexes
    sudo mdutil -E 
    
    // some other options:  -s = display status, -v = verbose
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 27, 2009 at 3:30 a.m. EDT
  • symbolic link
    #syntax to create symbolic link
    ln -s /export/space/common/archive /archive
    
    #example, link would be created in directory 'placement'
    ln -s /path/to/original/file/or/directory /path/to/the/placement
    
    #dropbox example
    ln -s /Users/username/Dropbox/theFolder /path/to/symbolic/links/directory
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 21, 2009 at 8:24 a.m. EDT
  • Bless CD To be opened automatically on mac when inserted
    sudo bless -folder "/Volumes/VolumeName/" -openfolder "/Volumes/VolumeName/"
    

    copy | embed

    0 comments - tagged in  posted by ludicco on Aug 19, 2009 at 9:55 a.m. EDT
  • Recursive dos2unix
    # Convert DOS file to UNIX, replacing DOS characters with UNIX equivalent.
    for file in `find . -type f`; do dos2unix $file $file; done
    

    copy | embed

    0 comments - tagged in  posted by winker on Aug 05, 2009 at 7:16 a.m. EDT
  • run unix command in background
    nohup bash syncr.sh &
    

    copy | embed

    0 comments - tagged in  posted by nick on Jun 23, 2009 at 11:21 a.m. EDT
  • Find with grep
     find ./ -name *.* -exec grep -i "something" '{}' \; -print
    

    copy | embed

    0 comments - tagged in  posted by mccu7pj2 on Jun 16, 2009 at 7:00 a.m. EDT
  • mirror website with wget
    mkdir -p /var/www/mirror
    cd /var/www/mirror
    wget --mirror –w 2 –p --html-extension –-convert-links –P /var/www/mirror/site http://www.yourdomain.com
    

    copy | embed

    0 comments - tagged in  posted by muanis on Jun 07, 2009 at 11:52 a.m. EDT
  • Get Current IP Address
    ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1 }'
    

    copy | embed

    0 comments - tagged in  posted by zvoase on Apr 28, 2009 at 8:55 a.m. EDT
Sign up to create your own snipts, or login.