Linux commands for viewing system information and for installed packages

Source: Internet
Author: User
Tags ftp site

System

uname -aView kernel/Os/cpu information
head -n 1 /etc/issueViewing the operating system version
cat /proc/cpuinfoView CPU Information
hostnameView computer Name
lspci -tvList all PCI devices
lsusb -tvList all USB devices
lsmodList the loaded kernel modules
envView environment variables

Resources

free -mView memory usage and swap usage
df -hView the usage of each partition
du -sh <目录名>To view the size of a specified directory
grep MemTotal /proc/meminfoView Total Memory
grep MemFree /proc/meminfoTo view the amount of free memory
uptimeView system uptime, number of users, load
cat /proc/loadavgView System Load

Disks and partitions

mount | column -tTo view the status of a mounted partition
fdisk -lView all partitions
swapon -sView all swap partitions
hdparm -i /dev/hdaView disk parameters (for IDE devices only)
dmesg | grep IDETo view IDE device detection status at startup

Internet

ifconfigTo view the properties of all network interfaces
iptables -LView firewall settings
route -nView the routing table
netstat -lntpView all listening ports
netstat -antpView all connections that have been established
netstat -sView network Statistics

Process

ps -efView All Processes
topShow process status in real time

User

wView Active Users
id <用户名>View specified user information
lastView User logon Logs
cut -d: -f1 /etc/passwdView all users of the system
cut -d: -f1 /etc/groupView system all groups \
crontab -lView scheduled tasks for the current user

Service

chkconfig --listList all system services
chkconfig --list | grep onList all system services that are started

Rpm

rpm -qaTo view all installed packages
In the Linux operating system, there is a system package that functions like "Add/Remove Programs" in Windows, but is much more powerful than Add/Remove Programs, which is Red Hat package Manager (RPM). The toolkit was first launched by Red Hat and later borrowed by other Linux developers. Because it saves Linux users a lot of time, it is widely used to install and remove software under Linux. Here is a brief introduction to the use of its specific methods.

  1. We get a new software, before the installation, it is generally necessary to check the contents of this package, assuming that this file is: linux-1.4-6.i368.rpm, we can use this command to view:
    rpm -qpi Linux-1.4-6.i368.rpm
    The system will list the details of the package, including information about how many files, file names, file size, creation time, compile date, and so on.
  2. All the files listed above are not necessarily installed at the time of installation, just like Windows under the installation of the program is divided into typical, full, custom, Linux will let you choose the installation method, at this time we can use this command to see the package will be installed in the system which parts, in order to facilitate our choice:
    rpm -qpl Linux-1.4-6.i368.rpm
  3. After selecting the installation method, start the installation. We can install this software with the RPM-IVH linux-1.4-6.i368.rpm command. During the installation process, if you are prompted to install the software or for other reasons, but if we do want to execute the installation command, you can add a parameter "-replacepkgs" after-IVH:
    rpm -ivh -replacepkgs Linux-1.4-6.i368.rpm
  4. Sometimes we uninstall one of the installed software, just execute the rpm-e <文件名> command.
  5. Upgrading low-version software is a good way to improve its functionality, which saves us the hassle of installing new software after uninstalling, to upgrade a software, just execute the following command: rpm -uvh <文件名> , note: The file name at this time must be to upgrade the software upgrade patch
  6. Another way to install software is the uniqueness of Linux, but also a manifestation of RMP's powerful features: installing software directly online via an FTP site. Once you have found the site containing the software you need and connected to this website, execute the following command to install online, for example, to install linux-1.4-6.i368.rpm online, you can use the command:
    rpm -i ftp://ftp.pht.com/pub/linux/redhat/...-1.4-6.i368.rpm
  7. In our use of computer process, it will inevitably be wrong to operate, if we mistakenly deleted a few files and affect the performance of the system, how to find out what exactly is missing files? The RPM package provides the ability to find corrupted files and execute this command: rpm -Va Linux will list all corrupted files for you. You can fix it through the Linux installation CD.
  8. Linux system files, in the course of use, will inevitably encounter the files we do not know, under Windows we can use the "Start/Find" menu to quickly determine which folder a file belongs to, in Linux, the following command line can help us quickly determine which package a file belongs to:
    rpm -qf <文件名>
  9. When each package is installed on a Linux system, the installation files will be "checked in" in the RPM database, so we need to look up the properties of one of the installed software just to find it in this database. Note: The query command at this point is different from the query described in 1 and 8, and this method only applies to packages that have already been installed! Command format:
    rpm -参数 <文件名>
Apt-getdebian

apt-get update--run the command after modifying/etc/apt/sources.list or/etc/apt/preferences. In addition, you need to run this command regularly to ensure that your package list is up-to-date.
apt-get install packagenameInstall a new package (see aptitude below)
apt-get remove packagenameUninstall an installed package (keep profile)
apt-get --purge remove packagenameUninstall an installed package (delete profile)
dpkg --force-all --purge packagenameSome software is difficult to uninstall, but also to prevent the application of other software, you can use this, but a bit risky.
apt-get autocleanApt will back up the installed or unloaded software on the hard drive, so if you need space, you can let this command delete the software you have deleted.
apt-get cleanThis command will also remove the backup of the installed software, but this will not affect the use of the software.
apt-get upgradeUpdate all installed Packages
apt-get dist-upgradeUpgrading the system to a new version
apt-cache search stringSearching for strings in the package list
dpkg -l package-name-patternLists all packages that match the pattern. If you do not know the full name of the package, you can use thePackage-name-pattern”。
aptitudeView the installed or available packages in detail. Similar to Apt-get, aptitude can be called by command-line mode, but only for certain commands-the most common are installation and uninstallation commands. Since aptitude has more information than apt-get, it can be said to be more suitable for installation and uninstallation.
apt-cache showpkg pkgsDisplays package information.
apt-cache dumpavailPrint the list of available packages.
apt-cache show pkgsDisplays the package record, similar to Dpkg–print-avail.
apt-cache pkgnamesThe name of all packages in the print package list.
dpkg -S fileThis file belongs to which installed package.
dpkg -L packageLists all files in the package.
apt-file search filenameFind packages that contain specific files (not necessarily installed) that contain the specified string in the file name. The Apt-file is a standalone package. You must first install it using the Apt-get install and then run Apt-file update. If apt-file search filename outputs too much content, you can try using Apt-file search FileName | Grep-w filename (shows only those filenames where the specified string appears as the complete word) or a similar method, for example: Apt-file search FileName | Grep/bin/(it is helpful to show only files that are located in folders such as/bin or/usr/bin, if you are looking for a specific executable file).

Linux commands for viewing system information and for installed packages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.