Basic Linux command for Beginner

Published by jackoonadmin in Linux on August 9th, 2011 | 1 Comment »

Below are some useful basic linux commands:

Command Example Description
cd cd /usr/tmp
cd test
change directory
cd .. back to parent directory
ls ls to list files and directories
ls /usr/tmp to list files and directories in the particular path
cp cp /usr/test.txt /home/test.txt copy file
cp -i /usr/test.txt /home/test.txt copy file, you will be prompted before it is overwritten
rm rm abc.txt remove/delete a file
rm -rf mydir remove all files & subdirectories from a directory
rm -rf mydir remove all files & subdirectories from a directory
rmdir rmdir mydirectory remove empty directory
rmdir rmdir mydirectory remove empty directory
mkdir mkdir newdirectory create a directory or folder
mv mv /usr/file.txt /home/ move file to another directory
mv file.txt file2.txt rename a file
find find -name missingfile.txt the command will search the file in current and sub-directories
find / -name missingfile.txt the command will search the file in root and sub-directories
find -name ‘*.txt’ the command will search the file end with .txt in current and sub-directories

One Response

  1. Prasath says:

    Here is a slightly more efeificnt way of doing the same thing:find ./ -name .svn -exec rm -rf {} \;When you use -exec find will execute the command for every result returned via the find query into the argument {}Another useful command is to only perform and operation on files that have not been added or modified. You can do this like so:svn status | grep ? | awk {print $2}’ | xargs rm -rfThis would remove any file that has been added to the repository.Breaking it downsvn status will return results like this:? fooM build/projects/Community.imlM build/build.propertiesPiping it through grep ? will give you:? foo Awk can be used to print out the column we want that is what the print $2 part of the awk command is for.foofinally pass the results to xargs rmHope this is interesting.cheers,A.J.

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>

© Jackoon.com
CyberChimps