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

Download and install vmware tools in Ubuntu linux

A simple step by step tutorial to install VMware tools in Ubuntu linux server in command line. It works with all the version of Ubuntu servers including the Latest Ubuntu 14.10.
Follow the detailed guide here 

Install Remote Desktop Client on CentOS6

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to install remote desktop CentOS?

Installing Windows RDP remote desktop client on CentOS Linux to connect to a Windows running machines with RDP protocol.
Applicable to : CentOS6, CentOS5, CentOS4, etc.
Install remote desktop client for CentOS from YUM repository
[root@server ~]# yum -y install rdesktop

After installing rdesktop on CentOS (run commands on X window)
Command usage:
# rdesktop [Options if any] <ipaddress>
Command example:
[root@server ~]# rdesktop 192.168.10.50
[root@server ~]# rdesktop -g 900x750 -u James 192.168.10.50

Connect RDP server with a different port number (eg: port 2500)
[root@server ~]# rdesktop -u James 192.168.10.50:2500

Available and usefull Options
-g  Desktop geometry (Window resolution)
-u  Username
-p  Password
-f  Full screen mode

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

Changing User ID and Group ID In Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How do i change the User IS and Group ID in Linux operating systems?

Every users and group has a unique ID (UID and GID) in linux operating system. You can change the default user ID of a user or a group ID of a group in Linux operating system. Use "usermod" and "groupmod" commands to modify the ID value of users/groups.

Changing user ID for the user account
# usermod -u <new user id> <username>
Example:
[root@server ~]# usermod -u 600 james

Changing the group ID of a group
# groupmod -g <new group id> <group name>
Example:
[root@server ~]# groupmod -g 700 accounts

Remove A User's Password in Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to remove a user password in linux ?

Removing a user password of a user account in Linux operating systems like Redhat, CentOS, Fedora, Ubuntu, Debian, etc. After removing the password of a user account, that user cannot login to the system without a password.
Command Usage: (Redhat, CentOS, Redhat, Ubuntu)
# passwd -d <username>

Command Example:
[root@server ~]# passwd -d james

Print all File names in a folder to a text file (For Linux and Windows)

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How can i print the file names of a folder into a text file.?
Q. How to print the dir/ls command output to a text file?

You can copy all file names in a folder/directory to a text file with the help of command prompt in windows and with command terminal in linux systems.
-->
After running the command, the output will write to a text file and save to current directory. The command is same for Linux and windows.

In Windows Operating systems(Windows 7,8, XP, Vista, 2008))
Open command prompt and run the below command
Command Usage:
C:\>dir <folder> >filename.txt
Example:
C:\>dir d:\Files\ >filename.txt

In Linux Operating systems(Redhat, CentOS, Fedora, Ubuntu, etc)
Open terminal and run the below command
Command Usage:
# ls > filename.txt
Example:
# ls /home/admin/ > contents.txt

Upgrading RPM Packages

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How can i upgrade a installed .RPM package?

Upgrading an installed .RPM package (Rehat Packet Management) on a Linux server is a simple task with RPM commands. Here you already have installed some version of the a package and you need to upgrade it to a latest version and erase all previous versions if installed. You need to be root or a super user to install/upgrading any packages. These command will work on all RPM based linux distributions like Redhat Linux, CentOS, Fedora, etc.
-->
Command Usage:
# rpm -Uvh <package.rpm>
-U :   upgrading the installed RPM package to the new version.

Example:
[root@server ~]# rpm -Uvh package.rpm

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

Sleep Command In Fedora CentOS And Redhat Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to sleep my linux system?

You can use "sleep" command in Fedora, CentOS and Redhat Linux operating systems.
Command Usage: sleep [number] [Option]
If no options specified seconds is the default option.

Eg: Sleep for 22 seconds
[root@server ~]# sleep 22

Sleep for 22 minutes
[root@server ~]# sleep 22m

Sleep for 3days 22minutes and 5 seconds
[root@server ~]# sleep 3d 22m 5s

Available Options
s:     Seconds
m:    Minutes
h:     Hours
d:     Days

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

Schedule Restart/Roboot in Redhat, CentOS, Fedora Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to schedule a restart or reboot in Fedora/CentOS/Redhat linux?

You can schedule a restart or reboot with "shutdown" command with reboot option (-r). Here is the command to schedule a reboot at 16:50 (Always use 24hr time format) with a sample output of the command.

[root@server ~]# shutdown -r 16:50
Broadcast message from root@server
        (/dev/pts/0) at 16:30 ...

The system is going down for reboot in 20 minutes!

How to cancel a scheduled restart
[root@server ~]# shutdown -c

Schedule Shutdown In Fedora, Redhat, CentOS Linux

FREQUENTLY ASKED QUESTIONS (Linux)
Q: How to schedule a shutdown in CentOS, Redhat, Fedora linux?

      Scheduling a shutdown is a simple task in RPM based Linux distributions like Redhat, CentOS, Redhat, etc. You can schedule a shutdown with the help of "shutdown" command. with "Time" options.

Here is the command to schedule a shutdown at 22:40 (24hr format). The Linux server will do an automatic shutdown/halt at 22:40 with a sample output of the command.

[root@server ~]# shutdown -h 22:40

Broadcast message from root@server
        (/dev/pts/0) at 22:30 ...
The system is going down for halt in 10 minutes!



How to cancel a pending/Scheduled shutdown in Linux
[root@server ~]# shutdown -c

Linux Command to Convert man page to PDF and TXT Files

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How do i convert Linux man pages to PDFs and text files?
Well.. Sometimes you need to convert and download the Linux man pages in different file formats like .pdf, .txt, etc. This article explains to convert the Linux man pages into PDF and Text files using built in commands and tools in Linux.

Convert and Download "yum" man page to .PDF file
[root@server ~]# man -t yum | ps2pdf - yum.pdf

Convert and Download  "yum" man page to .TXT file
[root@server ~]# man -t yum | ps2ascii - yum.txt

Tested in Fedora, Redhat and CentOS linux systems.

Where are man pages in Linux located

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How do i exit properly from the man page in Linux operating systems?

You can find the location path of all the man pages by the "manpath" command.
[root@server ~]# manpath
/usr/local/share/man:/usr/share/man
Here the man pages are located in "/usr/local/share/man" and "/usr/share/man"


Get useful tips: man page of "man"
[root@server ~]# man man

How to Exit From Man Pages in Linux Properly

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How do i exit properly from the man page in Linux operating systems?


You can always exit from the man pages by simply pressing "q" in linux operating systems. You can also find cool tips in reading man pages with the below command

[root@server ~]# man man

Finding PID of a Process in Fedora, Redhat, CentOS

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How do i find the Process ID (PID) of a process/service in Linux operating systems?

You can find the process id of a linux process in many ways. The simplest command to find it is "pidof" command. You can also use "ps" command fo find the Process ID of a Linux process. All these commands should work on all RPM based distributions like Fedora, Redhat, CentOS, etc.

Find PID of vsFTPd process using "pidof" command
[root@server ~]# pidof vsftpd
1634

Find PID of vsFTPd process using "ps" command
[root@server ~]# ps -e | grep vsftpd
1634   ?      00:00:00   vsftpd

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

How to Search a Word in a File in Linux

FREQUENTLY ASKED QUESTIONS (Linux Commands)
Q. How to search a word in a file or in multiple files in Linux using commands ?

You can use Grep command to search or find a given text word in a file or more than one files at once. Grep command will search the given text in the whole file and print the output.

Example:
To search the word "Amazing" in a file
[root@server ~]# grep Amazing sample.txt

The above grep command will search for the word "Amazing" in the file sample.txt

Search case sensitive
[root@server ~]# grep -i Amazing sample.txt


Clear Bash command history in Fedora, CentOS, Redhat

FREQUENTLY ASKED QUESTIONS (Linux)
Q. How to delete/clear bash command line history in Redhat, Fedora,CentOS ?

If you do not want to keep a history of of all your previously entered commands in linux? The below Commands will clear your entire bash command history in your machine.
[root@server ~]# history -c

or

[root@server ~]# rm -rf ~/.bash_history

Related Posts Plugin for WordPress, Blogger...

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