Saturday, 23 November 2013

How to create a user to ssh to the server and then only have super user permission to switch to root user?

I don't want to ssh to my linux server as root user. So I have disabled the direct root login through ssh. I am using a less privileged user to ssh to the server. But I don't want to give him sudo privilege. The only privileged command this user (less privileged user) should be able to run is to switch to root user. How can I achieve this?

I'm using Amazon Linux (which is actually centos based) in my ec2 instance. It comes with 'ec2-user' which has no password and but has sudo privilege and uses ssh key for login. I want to use password login for other users (and don't want to use ssh key for them)[So I can't disable password login "PasswordAuthentication  no" field in sshd_config file]. But I also want to set password for 'ec2-user' as I don't want to use sudo command without password. I have used below setup to achieve this.

How to delete file names with spaces older than 30 days in linux?

I want to delete files which are modified before 30 days from a public folder (uploads) in my linux server. The files are uploaded by different users so it includes white spaces and other characters in the file name. How can I automate this process?

You can use any of the below commands to achieve this: