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

Wednesday, August 21, 2019

SSH Server related basic command

Install

To install the openssh-server, you need to install the openssh-server package:
sudo dnf install -y openssh-server;

Start

To start the sshd daemon (openssh-server) in the current session:
sudo systemctl start sshd.service;

Stop

To stop the active (if any) sshd daemon in the current session:
sudo systemctl stop sshd.service;

Enable

To configure the sshd daemon to start automatically at boot time:
sudo systemctl enable sshd.service;
You will get an output similar to this:
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'

Disable

To configure the sshd daemon to stop automatic initialization at boot time:


sudo systemctl disable sshd.service;

Thursday, October 12, 2017

Searching text in the file contents inside a directory in linux

Sometimes, We need to find out specific string of text in the files' Contents of a directory of linux system. Its to look for text within the file, no tin the file name. 


In such case we can user the below command:


grep -r -l "specific test" /directory/path/full/*criteria_if_required_in_file_name*log

Sunday, November 1, 2015

Commands to get Hardware Information in Linux

1. lshw - List Hardware

    Lshw extracts the information from different /proc files.It reports detailed and brief information about multiple different hardware units such as cpu, memory, disk, usb controllers, network adapters etc.

2. lscpu

    This command reports information about the cpu and processing units. It does not have any further options or functionality.

3. hwinfo - Hardware Information

    Hwinfo is another general purpose hardware probing utility that can report detailed and brief information about multiple different hardware components, and more than what lshw can report.
   Command: $ hwinfo --short

4. Inxi

Inxi is a 10K line mega bash script that fetches hardware details from multiple different sources and commands on the system, and generates a beautiful looking report that non technical users can read easily.
    command: $ inxi -Fx

5. lspci - List PCI

    The lspci command lists out all the pci buses and details about the devices connected to them. The vga adapter, graphics card, network adapter, usb ports, sata controllers, etc all fall under this category.
    Filter out specific device information with grep.
   Command: $ lspci -v | grep "VGA" -A 12

6. lsscsi - List scsi devices

    Lists out the scsi/sata devices like hard drives and optical drives.

7. lsusb - List usb buses and device details

    This command shows the USB controllers and details about devices connected to them. By default brief information is printed. Use the verbose option "-v" to print detailed information about each usb port



8. lsblk - List block devices

To get the the list of all block devices, which are the hard drive partitions and other storage devices like optical drives and flash drives

9. df - disk space of file systems

Various partitions Information, their mount points and the used and available space on each.
    command: $ df -H

10. fdisk

To modify hard drive partitions Fdisk is a utility, and can be used to list out the partition information.
    command: $ sudo fdisk -l

11. Pydf - Python df

Its wriiten in python, that displays colored output that looks better than df


12. mount

The mount is used to mount/unmount and view mounted file systems.
    command: $ mount | column -t
                      $ mount | column -t | grep ext

13. free - Check RAM

Check the amount of used, free and total amount of RAM on system with the free command.
    command: $ free -m

14. hdparm

The hdparm command gets information about sata devices like hard disks.
    commnad: $ sudo hdparm -i /dev/sda

15. dmidecode

The dmidecode command is different from all other commands. It extracts hardware information by reading data from the SMBOIS data structures (also called DMI tables).
Commands:
    # display information about the processor/cpu
    $ sudo dmidecode -t processor

    # memory/ram information
    $ sudo dmidecode -t memory

    # bios details
    $ sudo dmidecode -t bios

16. /proc files

Many of the virtual files in the /proc directory contain information about hardware and configurations. Here are some of them   
    Commands:
    # memory information
    $ cat /proc/meminfo
   
    # cpu information
    $ cat /proc/cpuinfo

    #Partition Information
    $ cat /proc/partitions

    #Linux or Kernel Verison
    $ cat /proc/version

    #SCSI / Sata Devices
    $ cat /proc/scsi/scsi
   





Tuesday, November 26, 2013

Mysqladmin Commands in Linux

mysqladmin is a command-line utility the comes with MySQL server and it is used by Database Administrators to perform some basic MySQL tasks easily such as setting root password, changing root password, monitoring mysql processes, reloading privileges, checking server status etc.

1.To set MySQL Root password:
# mysqladmin -u root password YOURNEWPASSWORD
 
2.to Change MySQL Root password?
#mysqladmin -u root -p123456 password 'xyz123'
 
3.To check MySQL Server is running?
# mysqladmin -u root -p ping
 
4.To Check which MySQL version I am running?
# mysqladmin -u root -p version
 
5.To Find out current Status of MySQL server?
#mysqladmin -u root -ptmppassword status 

6.To check status of all MySQL Server Variable’s and value’s?
# mysqladmin -u root -p extended-status
 
7.To see all MySQL server Variables and Values?
# mysqladmin  -u root -p variables
 
8.To check all the running Process of MySQL server?
#mysqladmin -u root -p processlist
 
9.To create a Database in MySQL server?
# mysqladmin -u root -p create databasename
 
10.To drop a Database in MySQL server?
# mysqladmin -u root -p drop databasename
 
11.To reload/refresh MySQL Privileges?
# mysqladmin -u root -p reload;
# mysqladmin -u root -p refresh;
 
The reload command tells the server to reload the grant tables. The refresh command
 flushes all tables and reopens the log files.
 
12.To shutdown MySQL server Safely?
#mysqladmin -u root -p shutdown 

other commands:
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start
 
13.Some useful MySQL Flush commands
 
# mysqladmin -u root -p flush-hosts
# mysqladmin -u root -p flush-tables
# mysqladmin -u root -p flush-threads
# mysqladmin -u root -p flush-logs
# mysqladmin -u root -p flush-privileges
# mysqladmin -u root -p flush-status
 
 
14.To kill Sleeping MySQL Client Process?
to see: # mysqladmin -u root -p processlist
 
Run the following id with process id: 
# mysqladmin -u root -p kill 5 

15.To run multiple mysqladmin commands together?
#mysqladmin  -u root -p processlist status version 

16.To Connect remote mysql server:
# mysqladmin  -h 172.16.25.126 -u root -p
 
 
17.To execute command on remote MySQL server:
# mysqladmin  -h 172.16.25.126 -u root -p status
 
 
18.To start/stop MySQL replication on a slave server?
# mysqladmin  -u root -p start-slave
# mysqladmin  -u root -p stop-slave
 
19.To store MySQL server Debug Information to logs?
# mysqladmin  -u root -p debug
 
20.To view mysqladmin options and usage:
# mysqladmin --help 
 
 
 
Source