Linux Basic Commands E-mail
Article Index
Linux Basic Commands
Page 2
Page 3
Page 4
Files Commands

ls : The command ls is used to list the contents of a directory.

Examples:-

ls -l long listing
ls -R list current directory and all other directories within current directory
ls -a list hidden files
ls -CF list in column format and append '*' to executable files, '@' to symbolic linked files, '/' to directories
ls -r list in reverse alphabetically order
ls -t list more recent accessed files first
ls -lrt List files by date

You Can Wildcard characters with ls command


* asterisk symbol is used to represent anycharacter
? question mark is used to represent any single character
(from-to) Values entered within brackets represent a range for a single character
(!from-to) Values entered within brackets represent a range to exclude for a single character

cd - : Go to previous directory

cp : To copy files

Examples:-

will copy f1 to f2  if f2 doesnot exist, it will be created, but if it exists, it will be overwritten

$ cp f1 f2

If you want to copy file into directory testdir:

$ cp f1 testdir

Option i is basaically used as an ["interactive"] with cp command

$ cp -i f1 f2
cp: overwrite `f2'? n

Other options are with cp command

-f  [force] if an existing destination file cannot be opened, remove it and try again
-l  [link] links files it will not copy.
-p [preserve=mode],ownership,timestamps
-R, -r,[recursive] copy directories recursively
-s [symbolic-link] make symbolic links instead of copying
-v  [verbose] mode

rm : Delete files

Examples:-

rm f1      remove the file 'f1'
rm -i f*    prompt to remove each file in current directory starting with letter 'f'
rm xyz*  remove all files in current directory starting with letter 'xyz' without prompt

mv: command can be used for moving or renaming files

Examples:-

To rename file you can use this command

$ mv f1 f2

To move the f1 into [dir1]another directory

$ mv f1 dir1

You can use following option with this command

-f ,[force] prompt before overwriting
-i ,[interactive] prompt before overwrite
-S ,[suffix=SUFFIX]
-u ,[update] move only when the SOURCE file is newer than the destination file or when the destination file is missing

rm: Is used for removing files and directories.

Examples:-

To remove a file f1

$ rm f1

you'll be prompted before removing the file when you will use i option:

$ rm -i f1

deleting more files with single command:

rm
f1 f2



 

Translate

English French German Hindi Italian Portuguese Russian Spanish

Enter your email address :