Showing posts with label Linux Command. Show all posts
Showing posts with label Linux Command. Show all posts

Tuesday, April 2, 2019

Open port (Redhat)



  Open JBoss port (default port:8080)

a.       Use the firewall command to add port 8080
                                             i.            firewall-cmd --zone=public --add-port=8080/tcp –permanent
b.      Once you add the above firewall rule reload firewall service:
                                             i.            firewall-cmd –reload
c.       And check whether the port was added to ipatables rules:
                                             i.            iptables-save | grep 8080

Tuesday, August 8, 2017

How to test email using SMTP server



Telnet to your smtp server like
telnet smtp.mydomain.com 25
Syntax :
telnet {smtp_domain_name} {port_number}
And copy and paste the below
helo your_domain.com
mail from:<test@your_domain.com>
rcpt to:<to_email@your_domain.com>
data
From: test@your_domain.com
Subject: test mail from command line

this is test number 1
sent from linux box
.
Note : Do not forgot the "." at the end which represents the end of the message
I found this on the web, and added this to Stack Overflow as many end up here.

Monday, August 7, 2017

How to Install Telnet Client



1. Issue the following commands to confirm that telnet is installed or not :
# telnet localhost 80
If telnet client does not installed, it should return something like :
# telnet localhost 80
-bash: telnet: command not found
2. Verify telnet client using which command :
# which telnet
/usr/bin/which: no telnet in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
3. Issue the following command to install telnet client :
# yum install telnet -y
4. If telnet client installed, it should return something like :
# telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
or
# which telnet
/usr/bin/telnet

Thursday, January 5, 2017

Java Path in Linux



You can add one of the Java path to PATH variable using the following command.
export PATH=$PATH:/usr/java/jre1.6.0_24/bin/
You can add this line to .bashrc file in your home directory. Adding this to .bashrc will ensure everytime you open bash it will be PATH variable is updated.

Install Java on Linux



Java for Linux Platforms
  1. Change to the directory in which you want to install. Type:
    cd directory_path_name
    For example, to install the software in the /usr/java/ directory, Type:
    cd /usr/java/
  2. Move the .tar.gz archive binary to the current directory.
  3. Unpack the tarball and install Java
    tar zxvf jre-8u73-linux-i586.tar.gz

    The Java files are installed in a directory called jre1.8.0_73 in the current directory.
    In this example, it is installed in the /usr/java/jre1.8.0_73 directory.
  4. Delete the .tar.gz file if you want to save disk space.

Unpack the tarball and install Java



tar zxvf jre-8u73-linux-i586.tar.gz

The Java files are installed in a directory called jre1.8.0_73 in the current directory. 
In this example, it is installed in the /usr/java/jre1.8.0_73 directory.

Remove a Directory


Use the below command :

rm -rf lampp
It deletes all files and folders contained in the lampp directory.

In case user doesn't have the permission to delete the folder:

Add sudo at the beginning of the command :
sudo rm -rf folderName
Otherwise, without sudo you will be returned permission denied. And it's a good practice to try not to use -f while deleting a directory:
sudo rm -r folderName
Note: this is assuming you are already on the same level of the folder you want to delete in terminal, if not:
sudo rm -r /path/to/folderName
FYI: you can use letters -f-r-v:
  • -f = to ignore non-existent files, never prompt
  • -r = to remove directories and their contents recursively
  • -v = to explain what is being done

Copy File from one machine to another machine using SSH



Syntax:
scp <source> <destination>
To copy a file from B to A while logged into B:
scp /path/to/file username@a:/path/to/destination
To copy a file from B to A while logged into A:
scp username@b:/path/to/file /path/to/destination

Linux Command



  1. Copy Directory
  2. Copy File From One Machine To Another Machine Using SSH
  3. Directory Total Size
  4. Distribution Information
  5. How to install Telnet Client
  6. How to test email using SMTP server
  7. Ifconfig Command
  8. Install Java On Linux
  9. Java Path in Linux
  10. Open Port (Redhat)
  11. Open Web Browser
  12. Remove a Directory
  13. Rename a Directory
  14. Unpack the tarball and install Java
  15. Zip/Unzip

Rename a Directory



mv /home/user/oldname /home/user/newname

Open Browser



python -m webbrowser "http://www.example.com/"

Thursday, December 22, 2016

zip/unzip



If you are referring specifically to the Zip file format, you can simply use the zip and unzipcommands.
To compress:
zip squash.zip file1 file2 file3
or to zip a directory
zip -r squash.zip dir1
To uncompress:
unzip squash.zip
this unzips it in your current working directory.

Copy Directory



The option you're looking for is -R.
cp -R source destination/
If destination doesn't exist, it will be created.

Linux Distribution Information Command



If you want distribution information, it will vary depending on your distribution and whether your system supports the Linux Standard Base. Some ways to check, and some example output, are immediately below.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu Saucy Salamander (development branch)
Release:    13.10
Codename:   saucy

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu Saucy Salamander (development branch)"

$ cat /etc/issue.net
Ubuntu Saucy Salamander (development branch)

$ cat /etc/debian_version 
wheezy/sid
References:
http://unix.stackexchange.com/questions/88644/how-to-check-os-and-version-using-a-linux-command