[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Centos 5.4: How do I manage ftp space from command line.

Posted on 2011-10-13
15
Medium Priority
?
435 Views
Last Modified: 2013-12-16
I would like to manage some FTP space that is only accessible from my server. I don't want to install anything new. I just want to use the standard FTP command.

ie:

#ftp
ftp>

Could you show me how to (from the command line):

1. Login to the ftp account
2. Get a list of files and directories
3. Create a directory called "backups"
4. Download a file from the backups directory.
5. Upload a file to the backups directory.

Kind Regards,

Adrian Smith
0
Comment
Question by:AdrianSmithUK
  • 7
  • 7
15 Comments
 
LVL 6

Expert Comment

by:Jelcin
ID: 36961786
1. ftp [ipadress]
2. dir
3. mkdir backups
4. cd backups
5. get [file-from-ftp-directory]
6. put [file-from-local-directory]

for help type "help"
for more instructions on ftp type in the shell "man ftp"
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 36961836
Hi,

Yu can use vsftpd install it with this command:

yum install vsftpd

After the install is complete you can start it:

service vsftpd start

if you want to run it after reboot autoatically

chckonfig vsftpd on

once it is active you vcan ftp it from a remote host:

ftp your_cents_system

it will respond with user and pass prompts fill in the user information .

once you've logged on you will have a promt such as this:

ftp>

enter :

ls

and you'll get a listing of remote directory.

lls

will show you the contents of the current directory at your local system where you run ftp client.

mkdir backup

will create a directory called backup at the remote host

cd backup

will change your remote directory to newly created backup directory.

binary

will set your ftp to binary mode. (some ftp clients default to text mode which might disrupt binary content)

put filename


will send the file to the remote host


get filename


will get the file from the remote server.


If you want to get several files you'd better use

mput
or mget

these commands will also accept wildcard characters.

 

Cheers,
K.
0
 

Author Comment

by:AdrianSmithUK
ID: 36961873
Hi Jelcin

Thanks for the sppedy response. I'm getting an error at point 1. I typed

ftp> ftp backup500.onlinehome-server.info

I will also need to include my username and password at some point.

I know the ftp space is accessible because I have a shell script that uses it.

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:AdrianSmithUK
ID: 36961885
Hi KeremE:

Many thanks for the info but as I said in the question - I don't want to install anything.

I want to stay with an absolutely minimal server.
0
 
LVL 6

Expert Comment

by:Jelcin
ID: 36961892
If you are already in the ftp command line you need to press "o" for open a connection.
0
 

Author Comment

by:AdrianSmithUK
ID: 36961948
Hi Jelcin

Many thanks and you've earned the points. However, before I close the issue could you explain the difference between GET and PUT.

Could you also show me how to save a file to a directory called Fred on my server.
0
 

Author Comment

by:AdrianSmithUK
ID: 36961959
Sorry Jelcin - I see you mentioned the first poin already.
0
 
LVL 6

Expert Comment

by:Jelcin
ID: 36962027
Also important as KeremE mentioned:

binary
will set your ftp to binary mode. (some ftp clients default to text mode which might disrupt binary content)

If you are going to transfer text files (includes txt, html, shell scripts, css files etc) you need to set the file transfer mode to ascii using "ascii" command.

On the other hand if you are going to transfer binary files (like images, pdf, MS office files, compiled code or executables etc) you need to set the file transfer mode to binary using "binary" command.
0
 

Author Comment

by:AdrianSmithUK
ID: 36962103
Sorry, I think you missed the second part of my question 3 posts up.

To close the issue could you give me instructions on how to transfer a file from the ftp directory

FTP Directory:
backups/backup123.sql.gz (Gzip sql file)

Local Directory
fred/backup123.sql.gz


0
 
LVL 6

Expert Comment

by:Jelcin
ID: 36962272
1. Change the current local working directory to fred

2. ftp [ipadress] or ftp> o [ipadress]
3. dir
4. cd backups
5. binary
6. get backup123.sql.gz
7. quit



0
 
LVL 6

Expert Comment

by:Jelcin
ID: 36962301
"get" is to get files from FTP server and "put" is to upload files to the FTP server.
0
 

Author Comment

by:AdrianSmithUK
ID: 36962606
Sorry Jelcin - How do I get it into the directory stated above?
0
 
LVL 6

Expert Comment

by:Jelcin
ID: 36962879
wait a moment please i will do a screenshot of my shell
0
 
LVL 6

Accepted Solution

by:
Jelcin earned 2000 total points
ID: 36963227
You have to distinguish between the shell on your linux computer and the ftp command line you call within your linux shell.

To go to the directory of your choice (with your linux shell) on your local machine you just need four commands.

1. ls (list the content of the directory you are currently in)
2. cd (go to one of the directories within your directory you are currently in)
3. cd .. ( go one directory backwards )
4. pwd (prints the directory tree you are currently in)

so if you are in "/home/fred" (check by typing "pwd") directory and there is a directory called "download" in your /home/fred/ directory you can change to the "download" directory by typing "cd download". Than your current directory should be "/home/fred/download". If you want to go back in your directory tree just type "cd .." and you will be back in "/home/fred".

So first you need to go to the directory of your choice on your local machine (where you would like to store the files to be downloaded).
Than you can call the ftp command line, connect to the ftp server and download the file you need to.
The file will then be downloaded to the local directory you was in before you called the ftp command line.

Below is a log of my linux shell doing the described above...


 shell-log
0
 

Author Closing Comment

by:AdrianSmithUK
ID: 36963289
Many thanks. You're a star.

Kind Regards,

Adrian Smith
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question