SSH, or Secure Shell, is a powerful protocol that allows you to securely connect and interact with remote servers. It is an invaluable tool for administrators, developers, and anyone who needs to manage remote machines. Today, we’ll be sharing top 30 essential SSH commands that you can use in Putty, a free SSH client. These commands will arm you with the knowledge to navigate, manipulate files, monitor system performance, and much more on your server.
1. Entering the Fray: Connecting to a Host
Before you can start using commands, you need to connect to your remote host. The basic command for establishing a connection is:
ssh user@host
In case your server uses a different SSH port, use the -p option to specify it:
ssh -p port user@host
2. Getting Your Bearings: Navigating the Filesystem
First things first, where are we? This command will print the name of the directory you are currently in:
pwd
Want to peek around the directory? List your current directory’s content with:
ls
Time to move? Use cd to change your working directory:
cd directoryname
3. Hands-on: Managing Files and Directories
Creating a new file is a breeze with touch:
touch filename
Need a quick peek into a file’s content? Here’s how:
cat filename
For more detailed file editing, nano or vi will be your trusty allies:
nano filename
vi filename
Copying, moving, or deleting files? cp, mv, and rm have got your back:
cp sourcefile destinationfile
mv sourcefile destinationfile
rm filename
To manage directories, use mkdir to create and rmdir to remove them:
mkdir directoryname
rmdir directoryname
4. The Hunt: Searching and Monitoring
The find and grep commands are your best friends for searching files and patterns:
find / -name filename
grep pattern filename
For real-time system monitoring, use:
top
Want to trace back your steps? Simply type:
history
5. Playing it Safe: Secure Copying and Key Management
Securely transferring files is easy as pie with scp:
scp sourcefile user@host:destination
To generate a new SSH key and install it on a remote machine, use the following two commands:
ssh-keygen
ssh-copy-id user@host
6. Housekeeping: Network and Disk Management
To check if a specific service is running and on what port, use:
netstat -tuln
To check for the total disk space usage, and for the usage of a specific directory, use the following commands respectively:
df -h
du -sh directoryname
7. Rules of Engagement: Modifying Permissions and Ownership
To change file permissions and ownership, chmod and chown commands are used:
chmod permissions filename
chown user:group filename
8. Keeping Tabs: Monitoring, Downloading and Archiving
To monitor logs in real time, use the tail -f command:
tail -f /path/to/log/file
Quickly downloading a file from the web? Use wget:
wget url
For archiving and extracting directories, use tar:
tar cvf archive.tar directoryname
tar xvf archive.tar
Conclusion
To master SSH and Putty is to understand how these commands work and when to use them. Most of these commands have additional options and arguments, and you can always dig deeper using man command.
SSH and Putty open up a world of possibilities when it comes to remote server management. This list is just the beginning. The more you use these commands, the more comfortable you’ll get. Remember, the terminal is your canvas, and these commands are your brush strokes. So go ahead, open up Putty, and paint away!
Please share this post if you found it useful. If you are using Ubuntu and want to generate an SSH key pair, you may want to check our tutorial here.