Linux basic commands on – AWS EC2 instance.
Linux basic commands on AWS EC2 instance
ASs soon as we connect to AWS EC2 instance we get the prompt as below:
[ec2-user@ip-172-31-83-99 ~]$
- [ = opening square bracket
- ec2-user is the default user in AWS
- @ = at symbol
- ip-172-31-83-99 = Ip address
- ~ = Tilde character
- ] = closing square bracket
- $ = This is the default prompt for normal users in Unix/Linux.
Below are the commands executed on AWS EC2 Linux instance:
date
Date command gives the output of day month date and time & time zone.
Here
Time zone is UTC means Universal Time Coordinated
[ec2-user@ip-172-31-83-99 ~]$ date
Fri Jul 14 08:43:05 UTC 2023 |
uname
[ec2-user@ip-172-31-83-99 ~]$ uname Linux |
uname -a
[ec2-user@ip-172-31-83-99 ~]$ uname -a Linux ip-172-31-83-99.ec2.internal 6.1.34-58.102.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 27 21:38:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
id
id – print real and effective user and group IDs
[ec2-user@ip-172-31-83-99 ~]$ id uid=1000(ec2-user) gid=1000(ec2-user) groups=1000(ec2-user),4(adm),10(wheel),190(systemd-journal) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 |
who
[ec2-user@ip-172-31-83-99 ~]$ who ec2-user pts/0 2023-07-14 08:42 (18.206.107.28) |
who am i
[ec2-user@ip-172-31-83-99 ~]$ who am i ec2-user pts/0 2023-07-14 08:42 (18.206.107.28) |
man who
man means manual or to know help of any command.
For example : If we want to know more info/help on who command then we need to run as below.
More examples : man ls, man date, etc….
Note : man command will give more information, here it has been removed in the below output for easy understanding.
[ec2-user@ip-172-31-83-99 ~]$ man who
WHO(1) User Commands WHO(1) NAME |
pwd
pwd – print name of current/working directory
[ec2-user@ip-172-31-83-99 ~]$ pwd /home/ec2-user |
mkdir
mkdir – make directories/ make folders ( In Unix we called directories but in windows we called folders )
[ec2-user@ip-172-31-83-99 ~]$ mkdir devops |
Note : Directory has been created. To verify we need to run ls command.
[ec2-user@ip-172-31-83-99 ~]$ ls
devops |
More Options in ls command:
ls -l | Lists files in the long format. The files are displayed along with their mode, number of links, owner of the file, file size, modification date and time and filename. |
ls -t | Lists in order of last modification time (most recent first). |
ls -a | Lists all entries, including the hidden files. |
ls -d | Lists directory file instead of its contents. |
Is -P | Puts a slash after each directory. |
ls -u | Lists in order of last access time. |
touch
touch – change file timestamps.
[ec2-user@ip-172-31-83-99 ~]$ touch file1 [ec2-user@ip-172-31-83-99 ~]$ ls -l file1 -rw-r–r–. 1 ec2-user ec2-user 981 Jul 17 13:24 file1 |
See Also: