linux commands for working with files and directories

Monday, November 7, 2011

I am bit familiar with linux environments (redhat, Fedora), when I am working with linux environment, use essential commands which are very useful any time for any developers. Each commands definitions and functions are described step by step. Here I will describe simply not in comprehensive manner.

By typing man command on linux command line we can view more information about specific command. Also entering on 'q' can quit from the man view.

To be log into linux servers use puTTy and ssh clients applications which are free clients to log into linux. There are plenty of linux client programme available in the web.

cd - change directory
When people work on linux or windows mostly familiar with this is command
The cd is a command line command to change the current working directory.
xiscom@comitg20# cd pradeep

pwd - display the name of current working directory
if someone want to find current working directory path. Do this command on command line.

ls – Listing files
The ls command for listing files and directories of the current working location.

man ls and info ls provide more information about this command.

There are many options can be found related with this command.

Ls -l – gives long listing showing the file size and permissions.
ls -la – Gives a long listing of all files in the current directory including “hidden” files with names staring with a dot
ls a* – Lists all files in the current directory whose names start with a
ls -l *.doc – Gives a long listing of all files in the current directory whose names end with .doc
ls -h – prints sizses in human readable format.

mkdir - create a new directory
this command I use for creating new directory.

mv - move or rename a currently existing disk-file/directory
To move or rename a file ore directory use this command. If I want to copy a file one server to another then scp command must be used.

rm-delete one or more disk-files
If I want to remove file from the disk, using this rm command

rmdir - delete a directory
In this command remove a directory from the disk. Before remove aware of the data of directory. After removing we cannot restore the data.

cat – concatenates files
This command can be used to join multiple files together and print the result on screen.
xiscom@comitg20# cat struts-config.xml

If we run the cat command for both files, we can print together the result on screen.
xiscom@comitg20# cat struts-config.xml web.xml

cp- copy a disk file/directory to a new location
Copy one or more files to another location

Copy a file in the same server
cp filename tolocation

Copy a directory in the same server
cp -r directoryname tolocation

Copy file one ftp server to another
first ensure that two servers communication availability and check user privileges
First you must login to server1 where file is located.
where server2 can be IP or server name.

Filename: test.html
Path to copy : /root/test/
ftp user name : user

[server1]$ scp test.html user@server2:/root/test/
Password: 'provide the destination servers user password'

scp test.xml xis211@
xis211@'s password: xis211

copy an directory one server to another
scp -r INSTALLATION xis211@


  © Blogger template Writer's Blog by 2008

Back to TOP