Basic useful Linux commands for learners

View all Environment variables env command can be used to view all enviroment variable and its value for current logged user via terminal.

ubuntu@ip-xx-xx-xx-xx:~/maven/JavaProj$ env
XDG_SESSION_ID=13
rvm_bin_path=/home/ubuntu/.rvm/bin
GEM_HOME=/home/ubuntu/.rvm/gems/ruby-2.4.2
TERM=xterm
SHELL=/bin/bash
IRBRC=/home/ubuntu/.rvm/rubies/ruby-2.4.2/.irbrc
SSH_CLIENT=202.52.130.254 54904 22
OLDPWD=/home/ubuntu/maven
MY_RUBY_HOME=/home/ubuntu/.rvm/rubies/ruby-2.4.2
SSH_TTY=/dev/pts/0
USER=ubuntu

Set Environment Variables on Linux You can modify each environmental or system variable using the export command. Set the PATH environment variable to include the directory where you installed the bin directory with perl and shell scripts:

export ANT_HOME=/path/to/ant/dir
export PATH=${PATH}:${ANT_HOME}/bin:${JAVA_HOME}/bin
Above command will set value for variable ANT_HOME and append it to PATH

Unset a environment variable Enviroment variable can be removed from current user environment dynamically without any reboot and affecting other user or same user any other environment using unset command as follows

unset ANT_HOME
unset

Above command remove the ANT_HOME variable and it's value from current user enviroment without affecting same user other enviroment.

View verbose output for git command Normal git command will not show the output of communication performed with GIT server while executing clone/pull/push command. To view the output of full culr response header value, we need to set the verbose output as true while executing every git command as follows.

GIT_CURL_VERBOSE=1 git clone
GIT_CULR_VERBOSE=1 git push

command will output the request and response for curl command performand by git command.

ubuntu@ip-xxx-xx-xx-xxx:~/maven/JavaProj$ GIT_CURL_VERBOSE=1 git pull
* Couldn't find host git-codecommit.us-east-1.amazonaws.com in the .netrc file; using defaults
*   Trying 52.94.226.180...
* Connected to git-codecommit.us-east-1.amazonaws.com (52.94.226.180) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 596 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_CBC_SHA1
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: git-codecommit.us-east-1.amazonaws.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: CN=git-codecommit.us-east-1.amazonaws.com
*        start date: Thu, 14 Dec 2017 00:00:00 GMT
*        expire date: Fri, 14 Dec 2018 12:00:00 GMT
*        issuer: C=US,O=Amazon,OU=Server CA 1B,CN=Amazon
*        compression: NULL
* ALPN, server did not agree to a protocol
> GET /v1/repos/PHPWordPress/info/refs?service=git-upload-pack HTTP/1.1
Host: git-codecommit.us-east-1.amazonaws.com
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache
< HTTP/1.1 401 Unauthorized
Facebook Facebook Twitter Reddit

Leave a Reply