Linux noob command line hints

I've been working with Linux for a couple of years but I'm not sysadmin so I use the parts of the system that I need at work. Mostly different activities with user interface interactions (which is similar to Windows behavior). However working on remote servers, comparing data, transfering and managing projects requires ssh-ing, some file management, archiving, searching in file system, filtering data, hiding folders etc. Here there are few of the tips I've used in the past days and I find useful:

Create/Extract archive ('z' option could be added as well if working with tar.gz files):

tar cvf archive.tar directory

tar xvf archive.tar

Print/list the content of a tar archive:

tar -tvf archive.tar

Create an archive from a SVN-based project excluding SVN:

tar --exclude=.svn -c -f archive.tar projectdirectory

Works for copying an SVN directory with rsync without .svn subdirectories:

rsync --exclude=.svn -r somedirectory somenewplace

Find differences between 2 directories with changes in each file:

diff -r directory1 directory2

Print only file names of different files in 2 similar directories:

diff -r -q directory1 directory2

Filter the 2 directories comparison and hide the .svn entries from output

diff -r -q directory1 directory2 | grep -v .svn

Copy data directory from local machine to a remote machine via SSH (reverse paths for vise verse):

scp -r yourdirectory

Any tips from you?

Be Sociable, Share!
  • Twitter
  • Facebook
  • email
  • StumbleUpon
  • Delicious
  • Google Reader
  • LinkedIn
  • BlinkList Digg DZone Facebook Google Google Reader Magnolia reddit SlashDot Technorati

4 thoughts on “Linux noob command line hints

  1. Mario Peshev

    Deleting all files with given name pattern recursively from a directory:

    find /path -type f -name "*~" -exec rm {} +

  2. Mario Peshev

    Exporting variables, for, let’s say, Grails setup:

    export GRAILS_HOME=/home/theuser/Software/grails-2.1.0/
    export PATH=”$PATH:$GRAILS_HOME/bin”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>