Important CLI commands

Here are some of the important CLI commands I encounter while working on projects that includes SSH keys and Github on cloud servers

cd ~/.ssh

This command will take you to the root directory.


ssh-keygen -t ed25519 -C "support@adnan-tech.com" -f id_ed25519

This will generate an SSH key in the current directory. It will ask for file name and password, you can press enter to set the name as default (id_ed25519 and id_ed25519.pub) and password as empty (no password).

If you are working on a cloud server, you may encounter a problem where you have to reboot your server. In some cloud providers, the SSH keys generated in .ssh folders are deleted after reboot.

Make sure to add the id_ed25519 and id_ed25519.pub in your .gitignore, otherwise, they will be uploaded on the repository.


chmod 600 id_ed25519

Sometimes, when you try to execute some function based on that key, it will return an error “permissions for the key are too open”. Above command will set the permissions to 600 and you will be good to go.


cat id_ed25519.pub

In order to view the SSH key, you can run the above command. This will show you the public key, you can safely add it in your Github > Settings > SSH keys page.


GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git pull origin master

If you do created your SSH keys in your current directory and not in .ssh folder, then git pull or git push commands won’t work if your origin is SSH. But you can explicitly tell the git to use the SSH file in your current directory.


git config --global user.email "support@adnan-tech.com"
git config --global user.name "Adnan Afzal"

These commands often mentioned by the git itself when you try to write a commit message and you are not logged-in in the terminal.


unzip file.zip -d file

If you uploaded a zip file from file manager and do not see an option to extract (some hosting providers do not have extract option), then you can use the above command to extract it. It will extract “file.zip” to a folder “file”.


cp source destination

This will copy a file or folder from one folder to another. The source file/folder will remain, it will not be deleted.


mv source destination

This will move the file or folder from one folder to another. The source file/folder will be deleted after it is moved to a new location.


rm -rf file_or_folder

Above command will permanently remove a file or folder (no recycle bin). It will do it recursively, this is needed when you folders inside folders. It will not ask for confirmation, it will forcefully perform the action.


Below are the list of those important CLI commands discussed in this blog post along with some others too.

Important CLI commands

cd ~/.ssh
ssh-keygen -t ed25519 -C "support@adnan-tech.com" -f id_ed25519
ssh-keygen -t ed25519 -C "support@adnan-tech.com"
chmod 600 id_ed25519
cat id_ed25519.pub
GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git pull origin master
GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git push origin master
GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git fetch origin
GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git reset --hard origin/master
GIT_SSH_COMMAND="ssh -i id_ed25519 -o IdentitiesOnly=yes" git clean -fd
git config --global user.email "support@adnan-tech.com"
git config --global user.name "Adnan Afzal"
unzip file.zip -d file
cp source destination
mv source destination
rm -rf file_or_folder

Learn how you can manage an entire website using Git from here.