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

How to check the MD5 checksum of a downloaded file

 Issue:

You would like to verify the integrity of your downloaded files.

Solution:

WINDOWS:

Download the latest version of WinMD5Free.

Extract the downloaded zip and launch the WinMD5.exe file.

Click on the Browse button, navigate to the file that you want to check and select it.

Just as you select the file, the tool will show you its MD5 checksum.

Copy and paste the original MD5 value provided by the developer or the download page.

Click on Verify button.

MAC:

Download the file you want to check and open the download folder in Finder.

Open the Terminal, from the Applications / Utilities folder.

Type md5 followed by a space. Do not press Enter yet.

Drag the downloaded file from the Finder window into the Terminal window.

Press Enter and wait a few moments.

The MD5 hash of the file is displayed in the Terminal.

Open the checksum file provided on the Web page where you downloaded your file from.

The file usually has a .cksum extension.

NOTE: The file should contain the MD5 sum of the download file. For example: md5sum: 25d422cc23b44c3bbd7a66c76d52af46

 Compare the MD5 hash in the checksum file to the one displayed in the Terminal.

If they are exactly the same, your file was downloaded successfully. Otherwise, download your file again.


LINUX:

Open a terminal window.

Type the following command: md5sum [type file name with extension here] [path of the file] -- NOTE: You can also drag the file to the terminal window instead of typing the full path.

Hit the Enter key.

You’ll see the MD5 sum of the file. 

Match it against the original value.

Linux Administration Commands

As a system administrator, you may want to know who is on the system at any give point in time. You may also want to know what they are doing. In this article let us review 4 different methods to identify who is on your Linux system.

1. Get the running processes of logged-in user using w

w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:
  • Name of the user
  • User’s machine number or tty number
  • Remote machine address
  • User’s Login time
  • Idle time (not usable time)
  • Time used by all processes attached to the tty (JCPU time)
  • Time used by the current process (PCPU time)
  • Command currently getting executed by the users
 
Following options can be used for the w command:
  • -h Ignore the header information
  • -u Display the load average (uptime output)
  • -s Remove the JCPU, PCPU, and login time.

$ w
 23:04:27 up 29 days,  7:51,  3 users,  load average: 0.04, 0.06, 0.02
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
ramesh   pts/0    dev-db-server        22:57    8.00s  0.05s  0.01s sshd: ramesh [priv]
jason    pts/1    dev-db-server        23:01    2:53   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.00s  0.00s w

$ w -h
ramesh   pts/0    dev-db-server        22:57   17:43   2.52s  0.01s sshd: ramesh [priv]
jason    pts/1    dev-db-server        23:01   20:28   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.03s  0.00s w -h

$ w -u
 23:22:06 up 29 days,  8:08,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
ramesh   pts/0    dev-db-server        22:57   17:47   2.52s  2.49s top
jason    pts/1    dev-db-server        23:01   20:32   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.03s  0.00s w -u

$ w -s
 23:22:10 up 29 days,  8:08,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM               IDLE WHAT
ramesh   pts/0    dev-db-server        17:51  sshd: ramesh [priv]
jason    pts/1    dev-db-server        20:36  -bash
john     pts/2    dev-db-server         1.00s w -s

2. Get the user name and process of logged in user using who and users command

who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.
$ who
ramesh pts/0        2009-03-28 22:57 (dev-db-server)
jason  pts/1        2009-03-28 23:01 (dev-db-server)
john   pts/2        2009-03-28 23:04 (dev-db-server)
 
To get a list of all usernames that are currently logged in, use the following:
$ who | cut -d' ' -f1 | sort | uniq
john
jason
ramesh

Users Command

users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version. If the user using, ‘n’ number of terminals, the user name will shown in ‘n’ number of time in the output.
$ users
john jason ramesh

3. Get the username you are currently logged in using whoami

whoami command is used to print the loggedin user name.
$ whoami
john
 
whoami command gives the same output as id -un as shown below:
$ id -un
john
 
who am i command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.
$ who am i
john     pts/2        2009-03-28 23:04 (dev-db-server)

$ who mom likes
john     pts/2        2009-03-28 23:04 (dev-db-server)

Warning: Don't try "who mom hates" command.
Also, if you do su to some other user, this command will give the information about the logged in user name details.

4. Get the user login history at any time

last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:
  • User name
  • Tty device number
  • Login date and time
  • Logout time
  • Total working time
$ last jason
jason   pts/0        dev-db-server   Fri Mar 27 22:57   still logged in
jason   pts/0        dev-db-server   Fri Mar 27 22:09 - 22:54  (00:45)
jason   pts/0        dev-db-server   Wed Mar 25 19:58 - 22:26  (02:28)
jason   pts/1        dev-db-server   Mon Mar 16 20:10 - 21:44  (01:33)
jason   pts/0        192.168.201.11  Fri Mar 13 08:35 - 16:46  (08:11)
jason   pts/1        192.168.201.12  Thu Mar 12 09:03 - 09:19  (00:15)
jason   pts/0        dev-db-server   Wed Mar 11 20:11 - 20:50  (00:39

Automate Linux (Ubuntu) script

I looked for what you propose. For use of 'preseeding' with 'debconf-get-selections':
Code:
sudo debconf-set-selections <<< 'slapd/root_password password your_password'
sudo debconf-set-selections <<< 'slapd/root_password_again password your_password'
sudo aptitude -y install slapd
And i fell also on this thread:
[stackoverflow.com/questions/1202347/how-can-i-pass-a-password-from-a-bash-script-to-aptitude-for-installing-mysql]

Code:
sudo DEBIAN_FRONTEND=noninteractive aptitude install -q -y
or
Code:
#!/bin/bash

installnoninteractive(){
  sudo bash -c "DEBIAN_FRONTEND=noninteractive aptitude install -q -y $*"
}

installnoninteractive slapd
Also I found 'expect'. For the use of 'expect':
Code:
#!/bin/bash
aptitude update
aptitude install expect

VAR=$(expect -c '
spawn aptitude -y install slapd
expect "New password for the slapd \"root\" user:"
send "PasswordHere\r"
expect "Repeat password for the slapd \"root\" user:"
send "PasswordHere\r"
expect eof
')

echo "$VAR"

aptitude -y install slapd
but for 'expect' the need to install the package.

After testing all these solutions, i prefer:
Code:
DEBIAN_FRONTEND=noninteractive aptitude install -q -y

Tools to remote into Linux Environments

#yum groupinstall 'GNOME Desktop Environment' 'X Window System'

1) VNC

x11vnc – simples of this 3 methods to get remote access. VNC stands for Virtual Network Computing) is a very useful network graphics protocol
Perhaps you need to enable EPEL (Extra Packages for Enterprise Linux) repository. Run
#yum -y install epel-release
Now we can install x11vnc. This command will install server and solve all dependencies
#yum -y install x11vnc
Then we will protect server with password:
# x11vnc -storepasswd

Enter VNC password:

Verify password:

Write password to /root/.vnc/passwd? [y]/n y

Password written to: /root/.vnc/passwd
!Do not use simple password!
We ready to start server:
# x11vnc --reopen --forever -rfbauth ~/.vncpasswd &
You can check if servers started:
    #netstat -an | grep 5900

    tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN

    tcp6 0 0 :::5900 :::* LISTEN

    If its ok, simply try to connect to it using vncviewer.
    #yum -y install vnc
    #vncviewer YOUR_SERVER_IP
That's all! Now you have access to your desktop. After reboot just ssh again and do again
    x11vnc --reopen --forever -rfbauth ~/.vncpasswd &

2) Tigervnc server

Tigervnc - is a high-performance, platform-neutral implementation of VNC
   #yum install -y tigervnc-server
Lets copy example config and edit it:
    #cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

    #vi /etc/systemd/system/vncserver@:1.service
Example of config:
[Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target
    [Service]
    Type=forking
    ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
    ExecStart=/usr/sbin/runuser -l YOUR_NAME -c "/usr/bin/vncserver
    PIDFile=/home/YOUR_NAME/.vnc/%H%i.pid
    ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
    [Install]
    WantedBy=multi-user.target
Now enable autostart service and restart it:
    systemctl enable vncserver@:1.service
    systemctl restart vncserver@:1.service
And finally connect to it:
    #vncviewer YOUR_SERVER_IP

3) XRDP

xrdp is an Open Source Remote desktop Protocol server. First of all we need to install EPEL repository and xrdp server:
    #yum -y install epel-release
    #yum -y install xrdp
Now lets start server
    #systemctl start xrdp.service 
Check if its running, and add him to autostart.
#netstat -an | grep 3389 
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN
#systemctl enable xrdp.service
Thats all now you can connect to your server from any windows machine.

4) Teamviewer

Teamviewer does not exist in standard repos, so we need to install wget and download TeamViewer rpm package
    #yum -y install wget
    #wget https://download.teamviewer.com/download/linux/teamviewer.x86_64.rpm
Install it, using this command:
    #yum install teamviewer.x86_64.rpm
And set your password
    # teamviewer passwd YOUR_PASSWORD
    ok
    #systemctl start teamviewerd.service
Now you only need to get your id to connect
#teamviewer –info
  TeamViewer ID: 9XXXXXXX7
Try to connect to it using this id and password you set

5) FreeNX

FreeNX is a Remote Access solution based on enterprise class open source technologies by NoMachine. If you like exact this tool to get remote access you may upgrade to cloud version.
First of all we need to add e EPEL + nux-dextop repositories, for Centos 6:
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
For Centos 7
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
Install server and agent:
#yum install freenx-server nxagent 
Enable passdb authentication:
#echo 'ENABLE_PASSDB_AUTHENTICATION="1"' >> /etc/nxserver/node.conf
Now we need to create user for remote access and assign password for him:
# /usr/libexec/nx/nxserver --adduser bob 
NX> 100 NXSERVER - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
NX> 1000 NXNODE - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
NX> 716 Public key added to: /home/bob/.ssh/authorized_keys2
NX> 1001 Bye.
NX> 999 Bye

#/usr/libexec/nx/nxserver --passwd bob 
NX> 100 NXSERVER - Version 3.2.0-74-SVN OS (GPL, using backend: not detected)
New password:
Password changed.
NX> 999 Bye
Now we will install epel-repos and opennx client on your machine:
#yum install opennx
After starting opennx wizard you will be asked about session name,server address and port. Most important thing is to set your key. You need to copy key from servers /etc/nxserver/client.id_dsa.key and paste it general tab of your client session properties.