💻 Linux Basics Commands for daily uses.

💻 Linux Basics Commands for daily uses.

BASIC LINUX COMMANDS

Listing commands

ls option_flag arguments --> list the sub directories and files avaiable in the present directory

Examples:

  • ls -l--> list the files and directories in long list format with extra information

  • ls -a --> list all including hidden files and directory

  • ls *.sh --> list all the files having .sh extension.

  • ls -i --> list the files and directories with index numbers inodes

  • ls -d */ --> list only directories.(we can also specify a pattern)

Directoy commands

  • pwd --> print work directory. Gives the present working directory.

  • cd path_to_directory --> change directory to the provided path

  • cd ~ or just cd --> change directory to the home directory

  • cd - --> Go to the last working directory.

  • cd .. --> change directory to one step back.

  • cd ../.. --> Change directory to 2 levels back.

  • mkdir directoryName --> to make a directory in a specific location

Examples:

mkdir newFolder              # make a new folder 'newFolder'

mkdir .NewFolder              # make a hidden directory (also . before a file to make it hidden)

mkdir A B C D                  #make multiple directories at the same time

mkdir /home/user/Mydirectory   # make a new folder in a specific location

mkdir -p  A/B/C/D              # make a nested directory

--cd(change directory): it has two use cd folder1: it is used to go inside any particular folder cd ..: it is used to go first step back cd ../../..: it is used to go previous steps

--pwd(present working directory): it gave us the path of our directory/folder.

--clear: it is used to clear the terminal screen.

--history: it is used to listout all the commands that we used.

--touch: it used to create an empty file. ex- touch file1

--echo: it is also used to create a file. ex- echo "this is my new line" > file2

--nano: it is the best version of creating a file ex- nano file3 ctrl+s= to save it ctrl+x= to exit out

--vi : it is also used to create a file ex- vi file4 press i = to activate insert mode press esc= to deactivate insert mode press shift+:w+q+enter= to save it and exit out

--cat: it has two used it is used to see the content inside any particular file --ex- cat it is also used to create a file ex- cat > file6 ctrl+c: to save it and exit out

SSH AND SCP CONNECTION

What is SSH?

Secure Shell, sometimes referred to as Secure Socket Shell, is a protocol which allows you to connect securely to a remote computer or a server by using a text-based interface.

When a secure SSH connection is established, a shell session will be started, and you will be able to manipulate the server by typing commands within the client on your local computer.

System and network administrators use this protocol the most, as well as anyone who needs to manage a computer remotely in a highly secure manner.

$ ssh localhost
$ sudo apt-get install openssh-server ii.

username@host:-$ sudo service ssh status
• ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: active (running) since Fr 2018-03-12 10:53:44 CET; 1min 22s ago Process: 1174 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES

Main PID: 3165 (sshd)

Another way to test if the OpenSSH server is installed properly and will accept connections is to try running the sshlocalhost command again in your terminal prompt. The response will look similar to this screen when you run the command for the first time:

username@host:~$ ssh localhost

The authenticity of host 'localhost (127.0.0.1)' can't be established. ECDSA key fingerprint is SHA256:9jqmhko9Yo1EQAS1QeNy9xKceHFG5F8W6kp7EX9U3Rs. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.

username@host:~$

Enter yes or y to continue.

Congratulations! You have set up your server to accept SSH connection requests from a different
computer using an SSH client.

TIP

You can now edit the SSH daemon configuration file, for example, you can change the default port for SSH connections. In the terminal prompt, run this command:

sudo nano /etc/ssh/sshd_config

The configuration file will open in the editor of your choice. In this case, we used Nano.

If you need to install Nano, run this command:

sudo apt-get install nano

Please note that you need to restart SSH service every time you make any changes to the sshd_config file by running this command:

sudo service ssh restart

cd to c directory .....create a keys folder in that............store ur pem file in

FOR MORE

DO FOLLOW Kanishthika Singh

👀 I’m interested in learning and working with community , open source contribution and give back to the community.

⛷️ I'm currently working with Kubernetes, Docker, Ansible, AWS, Jenkins, Terraform, CI/CD, Git & GitHub

💞️ I’m looking to collaborate on GitHub and open source projects related to cloud computing,Devops ,Data.

📝 I regularly write articles on Hashnode

💬 Ask me about DevOps, Linux-Ubuntu, Kubernetes, Docker, AnsJenkins, CI/CD, DATA ,AI

📫 Reach out to me at