Change the permissions of files or directories. For example, changing permissions on a ssh key file for the current user.
chmod 400 ~/.ssh/id_rsa
- If you’re not logged in as root, use
sudowhen permissions denied. more info
+x is used to make a file executable.
chmod +x myshellscript.sh
Find all symlinks.
find . -type l -ls
Copy files and folders over ssh. For example, download home directory for user
gilfoyle from machine into the current directory.
scp -r email@example.com:/home/gilfoyle .
Upload folder and its files recursively. For example, with the root account, upload extracted Drupal devel module to
/var/www/modules using port 8022.
scp -P 8022 -r devel firstname.lastname@example.org:/var/www/modules/devel
Download folder and its files recursively. For example, with the root account, download the devel module into the devel folder within the current directory using port 8022.
scp -P 8022 -r email@example.com:/var/www/modules/devel devel
Install openssh server
apt-get install openssh-server
Unlocking the root account
usermod root -p password # enter new password to unlock root sudo passwd root
service ssh status
Configure openssh server
Allow root password login
# change PermitRootLogin prohibit-password # to PermitRootLogin yes
Disallow root password login
# change PermitRootLogin yes # to PermitRootLogin prohibit-password
Restart the service for any config changes to take affect
service ssh restart
Allows a user to run a command as another user, usually root. For a user to do this, they need to be added to the
usermod -aG sudo gilfoyle
Logout Ctrl + D and test new user sudo access. Substitute
0.0.0.0 with the server IP address.
ssh firstname.lastname@example.org # list files in the /root directory sudo ls -la /root
sudo is enabled for the new user account, root password login can be turned off in the sshd_config file.
unable to resolve host message when using
sudo, update the hosts file to contain the hostname for
127.0.0.1. For example, what is after @ in the command line prompt. e.g.,
sudo nano /etc/hosts 127.0.0.1 localhost vpshostname
Download package lists from repositories and update them to get information on the newest versions of packages and their dependencies.
- The Advanced Package Tool (apt) is primarily for Debian and Ubuntu Linux systems.
Fetch new versions of packages existing on the machine if APT knows about these new versions by way of
Does the same job as
apt-get upgrade, plus it will also intelligently handle the dependencies, so it might remove obsolete packages or add new ones.
These examples use
gilfoyle for the username.
Add a new user.