Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Send Message to Another User Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to send messages to terminal users on linux command line?

Use "write" command to send messages to Linux users who logged in using terminal. It will helpful if more users are logged in to a same Linux server via terminal and they all can communicate Linux users with text messages. You can send message to a Linux user in a special tty if one user is logged with more sessions.

Command usage:
# write <recipient's username>
or
# write <recipient's username> <tty name>
<type your message to the user>   and press enter

Example:
[root@server ~]# write admin
Hey Admin, How are you ?

Tip: press Ctrl+z to stop and exit

How the Recipient(admin) receives the message
[admin@server ~]# 

Message from root@server on pts/1 at 18:38 ...
Hey Admin, How are you?


Send message to a user in a different tty or pts
[root@server ~]# write admin pts/2
(message will send to admin logged in pts/2 only)
Tip: Use "w" command to identify the pts/tty of a logged in user

Where is Trash directory located on Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: Where is Trash folder location or path in linux?

  You can find the Trash (Recycle Bin) directory under the ".local/share/Trash/" location. And there will be two directories named "info" and "files", where "info" includes a "filename.trashinfo" file that includes the original file location and deleted date and time of all trashed files. "files" directory includes the full and original deleted files.
You can read and modify the trashed items/files also. And you can empty trash or delete files from trash using normal "rm" command in command line.
Please Note: This Trash directory only created when you delete a file to trash folder first.

Accessing Trash Directory Command line
Applicable to: RHEL, Redhat, CentOS, Ubuntu, Debian, Fedora, etc. 
[root@server ~]# cd ~/.local/share/Trash/
[root@server Trash]# ls
files   info

[root@server Trash]# ls files/
video.avi
[root@server Trash]# ls info/
video.avi.trashinfo

[root@server Trash]# cat info/video.avi.trashinfo

[Trash Info]
Path=/home/admin/Videos/video.avi
DeletionDate=2012-09-10T13:58:13


Install Teamviewer 7 on Ubuntu 12.04 and Debian

FREQUENTLY ASKED QUESTIONS (Ubuntu)
Q. How to install Teamviewer 7 on Ubuntu 12.04 ?

Teamviewer is a free* and secure remote desktop sharing cross platform application. Teamviewer works with Mac OS, Linux, Windows, etc.
Get Teamviewer 7 for Ubuntu/Debian operating systems

Or download it from command line
user@ubuntu:~$ wget http://www.teamviewer.com/download/teamviewer_linux.deb
user@ubuntu:~$ wget http://www.teamviewer.com/download/teamviewer_linux_x64.deb

Install Teamviewer 7

user@ubuntu:~$ sudo dpkg -i teamviewer_linux.deb

user@ubuntu:~$ sudo dpkg -i teamviewer_linux_x64.deb

*Teamviewer is free for personnel use only.

Wget: Download Files In Command Line In Linux

Downloading files from internet in command line is possible with the "wget" command. You can download any file from web like softwares, rpm packages, music files, etc with its web url. Many linux operating systems have wget preinstalled with. wget can download files with http, https and ftp protocols.

Check if wget is preinstalled on your linux
[root@server ~]# rpm -q wget
wget-1.12-1.4.el6.x86_64

If not, Install wget from YUM repository
[root@server ~]# yum -y install wget

Download a file with wget from http
[root@server ~]# wget http://example.com/file.zip
Wget with Username and password (http)
[root@server ~]# wget --http-user=USER --http-password=PASS http://example.com/file.zip

Download a file with wget from https
[root@server ~]# wget https://example.com/file.zip

Download a file with wget from ftp
[root@server ~]# wget ftp://example.com/file.zip
Wget with Username and password (FTP)
[root@server ~]# wget --ftp-user=USER --ftp-password=PASS ftp://example.com/file.zip

Download multiple files with wget
[root@server ~]# wget http://example.com/file1.zip http://example.com/file2.zip

Schedule Restart/Reboot In Ubuntu Using Command

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to schedule a restart/Reboot in Ubuntu Linux?

You can schedule a restart in your Ubuntu Linux server with "shutdown" command with Reboot switch(-t) and time options. A command example to schedule a restart ubuntu server at 22:00 (Use 24hr time format).

user@ubuntu:~$ sudo shutdown -r 22:00

How to cancel a scheduled restart in Ubuntu
user@ubuntu:~$ sudo shutdown -c

Schedule a Shutdown In Ubuntu/Debian With command

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to Schedule s shutdown in Ubuntu/Debian linux?

You can schedule a shutdown in Ubuntu Linux using "shutdown" command with halt switch (-h) and time. Below is an example command to shutdown your Ubuntu Linux server at 14:30. (use 24hr time format)

user@ubuntu:~$ sudo shutdown -h 14:30

How to Cancel a already scheduled shutdown
user@ubuntu:~$ sudo shutdown -c

For Shutdown Ubuntu Instantly
user@ubuntu:~$ sudo poweroff
or
user@ubuntu:~$ sudo shutdown -h

[SOLVED] Remote host identification has changed : Host key verification failed

FREQUENTLY ASKED QUESTIONS (Linux)
Q. Cannot connect to remote linux computer via SSH (Secure shell) getting Error message below

[root@server ~]# ssh 192.168.10.50
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
ac:c2:d2:47:81:14:39:f0:3f:ed:99:18:59:f:80:a1.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:1
RSA host key for 192.168.10.50 has changed and you have requested strict checking.
Host key verification failed.

How to Fix this ?
You may get this error message because of the RSA host key had changed (sometimes the ipaddress of the SSH Server has changed or you installed a new Operating system with the same ip address).

You should fix this error by correcting/deleting the host key of the server which you tried to connect via SSH.

Delete the RSA host key for 192.168.10.50
You can delete the saved SSH RSA key for the destination SSH server (192.168.10.50)
[root@server ~]# vi ~/.ssh/known_hosts
# And you can delete the line starts with the destination SSH server ipaddress/hostname.
(Move the curser to the ipaddress and press "d" twice to delete RSA Host key)
And you have all done, now save the file.

Now Connect to the SSH server
[root@server ~]# ssh 192.168.10.50

The authenticity of host '192.168.10.50 (192.168.10.50)' can't be established.
RSA key fingerprint is ac:c2:b2:d7:81:f4:39:80:3f:ed:a9:18:59:1f:80:a1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.50' (RSA) to the list of known hosts.
root@192.168.10.50's password:
[root@webserver ~]#

Still you cannot connect to the SSH server ?
Try Deleting the entire RSA host key of all the knows hosts. Dont worry the "known_hosts" file create and configured automatically when you connect to a new SSH server every time. And the RSA host key will be saved safe.
[root@server ~]# rm ~/.ssh/known_hosts
[root@server ~]# ssh 192.168.10.50

TCPDump Commands For Linux

Tcpdump is a free command based tool for capturing and analyzing a receiving/sending data packets. tcpdump will work on all the unix based operating systems like Ubuntu, Fedora, Redhat, CentOS, Debian, etc. tcpdump can capture the packets and write into a file.

Install tcpdump (Ignore if installed)
[root@server !]# yum -y install tcpdump
OR
user@server:~$ sudo apt-get install tcpdump

tcpdump commands
Monitor all the sending and receiving packets/protocols
[root@server !]# tcpdump

Monitor ICMP protocol on interface eth0
[root@server !]# tcpdump -i eth0 icmp

Monitor port 80/TCP on network interface eth0
[root@server !]# tcpdump -i eth0 -p tcp port 80

Monitor UDP ports
[root@server !]# tcpdump -i eth0 -p udp

Capture the tcpdump packets data into a log file
[root@server !]# tcpdump -i eth0 -p tcp port 80 -w captured.log

Read a captured log file
[root@server !]# tcpdump -r captured.log

Minicom: A Serial Communication Program For Linux


           Minicom is a powerful and simple text based serial communication program which distributed under GNU Public License for Linux based operating systems. Sometimes Minicom is preinstalled with Debian Linux.
It has a very simpler configuration menu and GUI interface. You can connect to all devices with this program includes CISCO routers, PBX systems,etc. Minicom has a Dialing directory with auto dialing feature. Individual users can use their own configurations with Minicom. Minicom also features to capture the serial data and save to a file in local directory. Minicom can be used with your physical serial devices like TTY.

Install Minicom from yum repository(Fedora & CentOS)

[root@server ~]# yum -y install minicom
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package minicom.x86_64 0:2.5-6.fc15 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================
 Package Arch Version Repository Size
=================================================================================
Installing:
 minicom x86_64 2.5-6.fc15 fedora 247 k
Transaction Summary
=================================================================================
Install 1 Package(s)
Total download size: 247 k
Installed size: 801 k
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 247 k
minicom-2.5-6.fc15.x86_64.rpm | 247 kB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : minicom-2.5-6.fc15.x86_64 1/1
Installed:
  minicom.x86_64 0:2.5-6.fc15
Complete!

Installation In Ubuntu and Debian OS's
user@ubuntu:~$ sudo apt-get install minicom


How to configure Minicom
Step1:
[root@server ~] minicom -s
(now you will get a Minicom configuration menu like below screenshot)
Minicom configuration menu















Step2: Now select "Serial Port Setup" from the main menu(see above screenshot, and you will get a menu like below screenshot.)



Step3: press "A" to change Serial device.Change to /dev/ttyS0        (capital "S" and zero "0")
Step4: Press "E" to configure Port setings as your device needs.
(For me, again Press "C" for bits per second: 9600 , Data bits:8, Parity:None, Stop bits:1, Flow control:None, etc.)
Step5: Select "Save setup as dfl" (from the main configuration menu) to save as Default.
Step6: Select "Exit from Minicom" (from the configuration menu) to Exit from configuration menu.

How to use Minicom
[root@server ~] minicom


Minicom has started..

Add DNS Server Address In Ubuntu Fedora Centos Redhat etc

After installing a Linux Operating system and configuring a Static ip address, you may need to add one or more DNS servers to resolve names. Then only you can communicate with domain names of websites and other servers. You can add more than one DNS server addresses as primary, secondary and so on.

This configuration should work in all Linux distributions like Redhat, CentOS, Ubuntu, Debian, Fedora, etc


Without a DNS server
Without a DNS server you can communicate with all servers by their ip addresses, and cannot communicate by their domain names.
[root@server ~]#  ping facebook.com
ping: unknown host facebook.com

Add DNS server Addresses
Add your DNS server address to the configuration file located in "/etc/resolv.conf"  as below. here i added Google's public DNS server addresses as my DNS server.
[root@server ~]# vi /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.4.4
#Now save the resolv.conf configuration file




Add DNS server in Interface config file
In RPM based Distributions like Redhat, CentOS, Fedora You can also add DNS server information in Network interface configuration file located in  
/etc/sysconfig/network-scripts/ifcfg-ethX
[root@server ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.10.50
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes
GATEWAY=192.168.10.1
DNS1=192.168.10.2
DNS2=192.168.10.3
DNS3=192.168.10.4

Test DNS Server
You not need to restart network daemon, 
Just go to browser and connect to any websites by name 
ping to websites
or [root@server ~]# host facebook.com
facebook.com has address 69.171.229.11
facebook.com has address 66.220.149.11
facebook.com has address 69.171.224.11
facebook.com mail is handled by 10 smtpin.mx.facebook.com.

Deny Terminal And Graphical Login To Linux Users

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to Deny users to login with terminal or GUI ?

To Restrict normal linux users to login into the operating system via terminal or Graphical login (GUI) change their default shell to "nologin". Same time allowing them to access other services like FTP, E-Mail login, Samba, etc.



Change User's Default Shell (RPM Linux)
[root@server ~]# usermod -s /sbin/nologin accountant
#The above command will modify the default shell to nologin shell (for user accountant)
And applicable to RPM based distributions like Fedora, CentOS, Redhat, etc.


Change User's Default Shell (Debian)
user@ubuntu:~$ sudo usermod -s /bin/false accountant
#Applicable to all debian based linux distributions like Ubuntu, etc


Find a User's default shell
[root@server ~]# cat /etc/passwd


Enable or Disable Anonymous access in vsFTPd Server

FREQUENTLY ASKED QUESTIONS (vsFTPd Server)
Q: How to Enable and Disable Anonymous access in vsftpd (FTP) server?


By enabling anonymous access in Linux FTP Server(vsFTPd) anyone can access the ftp server by using the username "Anonymous". so this anonymous user account will be enabled after doing this. But Its not secure in publicly accessible ftp servers. Disabling anonymous access is recommended.


[root@server ~]# vi /etc/vsftpd/vsftpd.conf

#in the 12th line edit line any of below two (uncomment the line if commented)
anonymous_enable=YES          #(to enable anonymous access)
    OR
anonymous_enable=NO          #(to disable anonymous access)
# Now save the vsftpd.conf configuration file and Restart the vsftpd daemon


[root@server ~]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

[SOLVED] Blocking utorrent Application in Squid

FREQUENTLY ASKED QUESTIONS (Squid proxy)
Q: How to block utorrent application and torrent large file downloading in squid?



Utorrent application uses all the unregistered posts 1025-65535 with random selection method. So blocking all those port numbers will block the bulk file downloading with utorrent application.


Edit the Squid.conf configuration file
[root@server ~]# vi /etc/squid/squid.conf


By default all the port numbers from 1025-65535 are configured as "Safe_ports" and allowed for browsing. 
So disable that ACL by adding a "#" infront of the line (see below)
#acl Safe_ports port 1025-65535          # unregistered ports


And create a new ACL for the same port range just below the above line (with different acl name, like below)
acl Denied_ports port 1025-65535


And deny browsing to the websites with denied port numbers (both normal and secure)
http_access deny Denied_ports
http_access deny CONNECT Denied_ports
# now save the squid.conf file


Reload Squid server with new configuration.
[root@server ~]# service squid reload


Verify Denying
Verify denying with squid access.log file 
[root@server ~]# vi /var/log/squid/access.log

Extra Tip: You can also block downloading of all ".torrent" files in squid (link below)
  

Monitor Memory usage in Fedora, Centos, Ubuntu, Redhat

FREQUENTLY ASKED QUESTIONS (Linux commands)
Q: How to check or know RAM memory usage in linux?


You may need to monitor the Memory usage in linux running servers. You can find the current RAM memory usage in "System Monitor" from menu in GUI . But in terminal, you need to run commands. There any few commands to find current memory usage.

Commands should work on all linux distributions like Fedora, Ubuntu, CentOS, Redhat, Debian, etc.
[root@server ~]# free
          OR
[root@server ~]# free -m        (Print the memory usage in MB)
Click on image to enlarge
[root@server ~]# cat /proc/meminfo
Click on image to enlarge

Squid limit web connections using maxconn acl

FREQUENTLY ASKED QUESTIONS (Squid proxy)
Q: How to limit number of symultaneous web connections in squid proxy?



Use "maxconn" ACL to limit the total number of symultaneous browser connections from a proxy client. If the maxconn access list configured to 5, the client can only access 5 simultaneous browser windows at a time.

Edit the squid proxy configuration file and create a maxconn acl
[root@server ~]# vi /etc/squid/squid.conf
acl accounts src 192.168.10.66/32                     #create a user acl to apply maxconn
acl limit5conn maxconn 5                                  # create maxconn acl
http_access deny accounts limit5conn                #apply maxconn acl to user acl
#Now save the squid.conf configuration file

Reload or restart squid
[root@server ~]# service squid reload
                  OR
[root@server ~]# service squid restart

Block a domain name in squid linux

FREQUENTLY ASKED QUESTIONS (Squid proxy)
Q: How to block a website (domain) in squid proxy server?


Squid can deny users accessing a specific website with a access denied error message. It can be done with squid "dstdomain" access lists (ACL).

Edit the squid.conf configuration file
[root@server ~]# vi /etc/squid/squid.conf

acl lan src 192.168.10.0/24                         # client ip range to block web sites
acl bad_sites dstdomain .foo.com .fooo.com            #Block two domains in single acl
http_reply_access deny bad_sites lan
#Add the above three lines and save the squid.conf file


Now squid server will deny browsing if anyone from the acl "lan" access the domain foo.com and fooo.com.
Note: Squid will also deny all sub domains of the blocked domain. for example if you block google.com, all Google's sub domains like news.google.com, maps.google.com,etc will also be blocked

Restart or reload squid with configuration changes
root@server ~]# service squid restart
or

[SOLVED] How to open a port in squid server

FREQUENTLY ASKED QUESTIONS (Squid Proxy)
Q: How to open/allow a particular port number in squid proxy?


By default the following TCP port numbers are opened in squid proxy server. 

acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http


If a web server listening on custom port 81/TCP, squid server will not allow to browse to  that server due to the port 81/TCP is not listed as Safe_ports.
Follow the steps to enable a port in squid server

[root@server ~]# vi /etc/squid/squid.conf
acl Safe_ports port 81                          # Add this line with the default port acls
http_access allow Safe_ports                # allow access
# add the above two lines to squid,conf

Restart or reload squid server with changes
[root@server ~]# service squid reload
                or
[root@server ~]# service squid restart

How to block ports in squid proxy

FREQUENTLY ASKED QUESTIONS (Squid Proxy)
Q: How to block a particular port number in squid proxy?

You can block a specific port number(port filtering) in squid proxy server. By blocking particular ports, you can restrict the use of some protocols/services/websites/applications through squid proxy.

For example to block ftp traffic all you need to do is block the port 21/TCP. same way you can block all https sites by blocking port 443/TCP. and so on...
Login as supersuer(root) and edit the squid's configuration file and block ports via ACLs.
This configuration will work in all linux distros like Fedora, redhat,CentOS,ubuntu, debian.


ACL based port blocking in squid
For example to block port number 443/tcp,(all the "https" sites will be blocked)
[root@server ~]# vi /etc/squid/squid.conf

acl Bad_ports port 443           #(create acl for port 443/tcp)
http_access deny Bad_ports             #(block port 443/tcp)
#now save the squid.conf file


Restart or reload squid with new configurations
[root@server ~]# service squid reload
                or
[root@server ~]# service squid restart


Test: Try to access some https sites eg: https://www.google.com (will be denied normally)


Important: By default the following port numbers will be added as "Safe_Ports" and open for browsing. and all the ports except listed below will be blocked by default.
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
Disabling the each above lines in squid.conf will block the appropriate ports. For example to block port 777/tcp, add a "#" infront of the same line (see below)
#acl Safe_ports port 777         # multiling http

Thanks for visiting...... add your comments and share with friends...

[SOLVED] Block Downloading File Types Like mp3, exe, zip, etc In Squid

FREQUENTLY ASKED QUESTIONS (Squid proxy)
Q: How to block particular file types or file extensions in squid proxy ?


Squid server can block/deny downloading particular file types like pictures, musics, videos, executable files etc. This file content filtering in squid is based on the file extension types like .exe, .mp3, .avi, .jpeg, .torrent, .zip etc. 


Blocking file types in squid
First of all, create an ACL file includes all the file types to block downloading them.
[root@server ~]# vi /etc/squid/bad_files.acl
\.[Ee][Xx][Ee]$                                       #block downloading exe executable files
\.[Mm][Pp]3 $                                         #Block mp3 music files
\.[Zz][Ii][Pp]$                                          #Block ZIP archive files
\.[Jj][Pp][Ee][Gg]$                                  #Block jpeg picture files
\.[Aa][Vv][Ii]$                                          #Block avi video files
\.[Tt][Oo][Rr][Rr][Ee][Nn][Tt]$                 #Block torrent files
#(Add the above required file extensions types and save the file)

Then, edit the squid configuration file and add an ACL for above created acl file.

[root@server ~]# vi /etc/squid/squid.conf
acl lan src 192.168.10.0/24                  (specify address range to deny downloading files)
acl badfiles urlpath_regex "/etc/squid/bad_files.acl"             (ACL for blocked file types)
http_access deny badfiles lan                                               (Deny the file types to lan)
#(Add the above three lines and save the squid.conf file)


Restart or reload squid server 
[root@server ~]# service squid reload
                       OR
[root@server ~]# service squid restart


#Verify the file type filtering/blocking by downloading any files from the Internet

Other Squid Related Articles

How to install vim in Ubuntu

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to install vim text file editor in Ubuntu linux?

VIM is the most compatible and widely used advanced text editor for Linux under GPL License. VIM is the improved version of "VI" editor. Vim is most suitable for all kinds for text based editing like configuration file editing. A GUI based VIM editor named "VIM-Gnome" is also available.


Install full vim editor in Ubuntu
user@ubuntu:~$ sudo apt-get install vim

Install Gnome GUI based vim editor in Ubuntu
user@ubuntu:~$ sudo apt-get install vim-gnome




Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons