chmod syntax in FTP-Client on all subdirectories - ftp

Which ftp client or which syntax allows easy chmod for sub-directories?

LFTP allows for recursive CHMOD if the client allows it. You can accomplish this by logging in with LFTP from a Unix/Linux CLI and then run the following:
chmod -R 0755 /www/directory/*
You could also setup a real nifty Bash script for this:
#!/bin/bash
lftp <<EOF
set ftp:ssl-allow no
set ftp:passive-mode true
set ftp:list-options -a
open -u [user],[password] [host]
chmod -R 0777 /www/directory/*
EOF
Of course LFTP does not distinguish between files and folders, for running this command on only files/folders respectively I would suggest using FileZilla. It allows this when running the command on a folder.

I'm pretty sure Filezilla does it

ncftp will support the chmod command if the FTP Server supports it.

As the answer from #Ken G suggests, this is more likely to be a question of "what does the FTP server support".
I tried ncftp (running under Cygwin on Win XP) against Sun FTP running on Solaris 10 (where chmod -R is supported by the o/s version of chmod). I got an error back:
ncftp /work1/jleffler/tmp > chmod -R g+x *
chmod g+x: server said: 'SITE CHMOD -R g+x': command not understood.
chmod *: server said: 'SITE CHMOD -R xx.pl': command not understood.
ncftp /work1/jleffler/tmp >
My suspicion is that few if any systems make it easy. It would be worth checking out whether the NCFTP server helps you.

To chmod all subdirs from where you are (recursive):
chmod -R *

chmod -R 755 {DIR}
You recurse with -R

Related

Chmod command over remote server using ssh NOT working

I have a bash script that copies over files from local to remote server using scp. Once all of the transfer is done, I run chmod command over the ssh to open up all of the permission. The problem is that it intermittently works and does NOT chmod 777 properly all the time. Any way I can verify that chmod command executed definitely (maybe using return code or something)? I do have my ssh keys setup so I do NOT need to enter password upon doing ssh or scp. Below is the snippet of my code
#copy over the files from local machine to remote server
scp file1.txt file2.txt file3.txt 10.111.222.333:/home/user1/fileDir/
#open up the permissions on the remote server
ssh -qX 10.111.222.333 chmod -R 777 /home/user1/fileDir
You could try:
ssh server "chmod 755 file |echo $?"
which would return 0
The |echo $? is checking the return code for the command ran.

Chown directory via SSH on server using NPM script

I am trying to chown a directory via an NPM script. The script looks like the following:
chown -R 755 www-data root#XXX.XXX.XXX.XX:/var/www/test.com
But the message I get back is: chown: www-data: No such file or directory even though this exists. Any ideas much appreciated.
chown operates locally, not on remote servers. In your example, chown is attempting to operate on ./www-data and ./root#XXX.XXX.XXX.XX:/var/www/test.com, which don't exist in the directory of wherever you were when you executed the command.
You will need to execute chown as a command through ssh:
ssh root#XXX.XXX.XXX.XX chmod -R 755 /var/www/test.com/
Fixed this with following script.
ssh root#XXX.XXX.XXX.XX chmod -R 755 /var/www/test.com/
(I needed to login to the server first).

Get permission to work with files on my Amazon EC2 Ubuntu server using FTP-WinSCP

I have an Ubuntu server on Amazon, I installed everything for working with it (php, mysql, phpmyadmin, apache..), The problem is that I cant move around or edit files using the FTP.
I get the error message:
Permission denied.
Error code: 3
Error message from server: Permission denied
from my WINSCP.
The only way I can trancefer/edit file is using 'putty' with the sudo/nano command.
I found a lot of information about this on google, but there are no updated soulution I can find. Linux isn't my usual work-space.
How do I get the permissions working for the WINSCP ?
A lot of answers say to change permissions on /var/www/ ... however AWS shortcuts out of the WWW folder and into the /var/app/current/ directory. If all else fails try:
sudo chown -R -v ec2-user /var/app/current/
On Ubuntu image in AWS, default user is ubuntu. Instead of using system folders like /var/... better to use /home/your_folder. Then change the ownership using {chown} command. For eg.
$ sudo chown -R -v ubuntu /home/your_folder/
This will change the ownership of 'your_folder' and contents inside it from 'root' user to 'ubuntu'. Then Winscp should be able to upload/delete/create files using SFTP/FTP etc..
I had the same issues. The solution is: You can solve this by changing WordPress ownership type:
sudo chown -R www-data:ubuntu /var/www/wordpress
Then, Change the right permission for the particular files and directories, type command
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;
Apart from this, set the following important files to chmod 600 so that only the owner can fully read and write access to these files:
sudo chmod 600 /var/www/wordpress/wp-config.php
sudo chmod 600 /var/www/wordpress/.htaccess
Then everything will work. You will be able to access your wordpress files
for me using free tier from cloud providers will not give you root access, to fix this you have to change folder permission from SSH or try this solution
OS: windows 10 Pro
Open WinSCP instead of SFTP you select SCP go to advance settings click on SCP/Shell and change the shell option to sudo su -
Now you will be able to get permission.
Change file permision by command chmod 777 /var/app/current/ and transfer files to the directory

Why does the lftp mirror command chmod files

I'm very new to lftp, so forgive my ignorance.
I just ran a dry run of my lftp script, which consists basically of a line like this:
mirror -Rv -x regexp --only-existing --only-newer --dry-run /local/root/dir /remote/dir
When it prints what it's going to do, it wants to chmod a bunch of files - files which I grabbed from svn, never modified, and which should be identical to the ones on the server.
My local machine is Ubuntu, and the remote is a Windows server. I have a few questions:
Why is it trying to do that? Does it try to match file permissions from the local with the remote?
What will happen when it tries to chmod the files? As I understand it, Windows doesn't support chmod - will it just fail gracefully and leave the files alone?
Many thanks!
Use the -p option and it shouldn't try to change permissions. I've never sent to a windows host, but you are correct in that it shouldn't do anything to the permission levels on the windows box.
I think that you should try
lftp -e "mirror -R $localPath $remotePath; chmod -R 777 $remotePath; bye" -u $username,$password $host

Tomcat startup script permission on Mac OS X

I'm struggling with a Mac OS X 10.5.8 that I've started using recently for development. I successfully installed tomcat and create launchd.conf for my environment variables.
I believe it works fine. Coz I can build a project with Netbeans using maven and cargo plugins successfully so i found online a script for start and stop the tomcat
#!/bin/bash
case $1 in
start)
sh /Library/apache-tomcat-6.0.20/bin/startup.sh
;;
stop)
sh /Library/apache-tomcat-6.0.20/bin/shutdown.sh
;;
restart)
sh /Library/apache-tomcat-6.0.20/bin/shutdown.sh
sh /Library/apache-tomcat-6.0.20/bin/startup.sh
;;
*)
echo "Usage :start|stop|restart"
;;
esac
exit 0
That script was created in nano in sudo sh
but when i want to run it. is spit out this
sh: /usr/bin/tomcat: Permission denied
I've added chmod 755 *.sh and *.bat inside /Library/apache-tomcat-6.0.20/bin
Still access denied so what do I go around that? I have the admin privileges on the machine.
Thanks for reading
Go to Tomcat bin directory and run the below command:
chmod +x *.sh
This worked for me.
Where did you install the tomcat script to? I'd recommend you install it to /usr/bin. Once installed, make sure the permissions are correct (i.e. chmod 755 /usr/bin/tomcat). You can then confirm with ls -l /usr/bin/tomcat.
If you still get errors once the permissions on /usr/bin/tomcat are correct, then you can add the following two lines following the #!/bin/bash line.
set -x
set -v
With the above lines, bash will output additional information that will allow you to tell what's being executed and where the error is happening.
1) Go to the tomcat directory, which preferably should be "/usr/local/folder-name"
2) Check for the permissions for the folder: ls -l
3) Change the permissions using: sudo chmod -R 755 folder-name
4) Change the owner to the current owner: sudo chown -R owner-name:group-name folder-name
e.g sudo chown -R userName:admin folder-name
Try executing the script again and it should work.

Resources