Last active
November 18, 2021 22:02
-
-
Save Mahedi-61/c8fa8f70cc8e160226e7fd55c556c5af to your computer and use it in GitHub Desktop.
useful unix command for beginners to work in remote server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This gist contains unix command useful for beginners who started working in remote server for their project. | |
# machine: Ubuntu 16.04 | |
### Connection | |
# connecting to a remote system using SSH (Secure Shell) | |
ssh <remote_host> | |
# for different username on the remote system | |
ssh <user_name@remote_host> | |
# adding new user to sudo group | |
sudo adduser <user_name> sudo | |
# if X11 forwarding is enabled on both computers, GUI of remote system can be opened on local system | |
ssh -X <remote_host> | |
# for opening remote GUI install package "caja" | |
sudo apt-get install caja | |
caja | |
# for connection closed (logout) | |
exit | |
### INTERESTING ### | |
# if you server machine doesn't have any static IP then do the following | |
# make an account https://www.duckdns.org/ | |
# mahedi.duckdns.org | |
# if you don't have ssh then install | |
sudo apt-get install openssh-server | |
ssh <user_name@remote_host> | |
### Secure Copy | |
# for secure copying file from your local host to remote server | |
scp <your_local_file.txt> <user_name@remot_server:/your/remote/directory> | |
# for secure copying file from remote server to your local host | |
scp <user_name@remot_server:your_remote_file.txt> </your/local/directory> | |
### Working in FTP Server | |
## (easy_way) using FileZilla | |
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu xenial-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list' | |
# install the key, to trust Ubuntu that the packages is from | |
wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add - repository | |
# now install ftp clients | |
sudo apt install filezilla | |
## (using ftp command) useful when work remotely worked on a server over an SSH session | |
# establishing an FTP connection | |
ftp <domain.com> | |
# downloading files from FTP server | |
lcd </your/local/directory> | |
get <remote_files> | |
# downloading several files form server (for example: xls files) | |
mget *.xls | |
# uploading files with ftp server | |
put /path/file | |
# uploading several files on ftp server | |
mput *.xls | |
# closing ftp connection | |
exit | |
### Handling Large Data | |
# splitting large file into small parts is useful when the file is too large or upload speed is too slow | |
# compress the file with tarball archiver | |
tar -czvf <archive_name.tar.gz> </path/to/folder> | |
# compress the file with of tar.xz file | |
tar -xf <archive_name.tar.xz> </path/to/folder> | |
# split up file archive into small parts (5G). | |
split -b 5G <archive-name.tar.gz> <"parts-"> | |
# joining files | |
cat parts-* > folder | |
### keep processes running on remote server after ending ssh session | |
# using nohup command | |
nohup process_running_commnad > filename.txt 2>&1 & | |
# "2>&1" for standard error writing and last "&" for disown | |
# for killing nohup | |
kill -9 PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment