Map command in linux

How to Check Memory Usage of Process with Linux pmap Command

The Linux pmap command displays the memory usage map of a process or multiple processes. Pmap reports information about the address space or memory usage map of a process.

Pmap is actually a Sun OS command and Linux supports only very limited number of features. But it is very helpful for finding the complete address space of a process. To check memory usage of process we need PID or unique process ID of running process, we can get PID from /proc or regular commands like top or ps.

Earlier we talked about process memory check using ps and top command, this tutorial I will teach how to use pmap command.

Usage syntax

Lets check the basic syntax of pmap command.

In the output, it displays total address, kbytes, mode and mapping.

Options

1) Memory usage map of single process

To check memory usage of a single process use map command followed by the PID number.

Let’s check an pmap example:

2) Memory usage map of multiple processes

We can check memory map of multiple processes by inserting multiple PIDs. For that add multiple PIDs with adding space.

3) Extended memory map about a process

To print extended memory information of a process use -x option. Here Address, Kbyte, Dirty, RSS, mode and mapping contains information as below:

Extended and Device Format Fields

Conclusion

In this tutorial we learn how to use pmap command to check memory information single and multiple processes. If you have any questions or feedback, feel free to leave a comment.

Источник

pmap command in Linux with Examples

The pmap command in Linux is used to display the memory map of a process. A memory map indicates how memory is spread out.

Syntax:

Example:

Options:

Example:


-p : This option is used to display the full path to the files.

Example:


-d : This option is used to display the device format.

Example:


-q : This option is used to ignore the column names while displaying the report of the memory map.

Example:


-A : This option is used to display results to the given range. Notice that the low and high arguments are single string separated with a comma.

Example:
-XX : This option is used to display everything the kernel provides.

Example:
-n : This option is used to create a new configuration.

Example:
-c : This option is used to read the default configuration.

Example:

  • -h : This option is used to display help text.
  • -v : This option is used to display the version information and exit.
  • Источник

    Linux Commands — Complete Guide

    If you are a beginner in Linux you might have started using the command line. Once familiarized it is fairly easy to work from the terminal and that why most Linux sysadmins prefer over the GUI.

    This tutorial we did best efforts to add most frequently used and important Linux commands you should know and remember. If you are looking for Linux cheat sheet we have in a downloaded format.

    System related Linux commands

    These commands are used to view and manage Linux system-related information.

    1. uname

    Uname command is used in Linux to find operating systems information. Uname had many options that can provide kernel name, kernel version, CPU type and hostname.

    The following uname command with a option displays all information about the operating system.

    2. uptime

    Information about how long the Linux system has been running is provided using uptime command. System uptime information is gathered from ‘/proc/uptime’ file. This command will also display the system load average.

    From the following command we can understand that the system is up and running for the last 13 mins.

    3. hostname

    You can display your machine hostname by typing hostname in your terminal. With -i option you can view the ip address of the machine and with -d you can view the domain name.

    4. last

    Linux’s last command is used to see who is the last logged in user into your server. Last command displays a list of all user logged in (and out) from ‘/var/log/wtmp’ since the file was created.

    You just need to type ‘last’ on your terminal. Here’s is an example

    5. date

    In Linux, date command is used to check the current date and time of the system. This command allows you to set custom formats for dates.

    As an example, by using ‘date +%D’ you can view the date in ‘MM/DD/YY’ format.

    6. cal

    By default, cal command display the calendar of the current month. With -y option you can view the calendar of the whole year.

    7. w

    By default, w command displays who is currently logged in into your machine and what they are doing.

    8. whoami

    Whoami command prints the user name of the currently logged in user. It is similar to id -un command.

    9. reboot

    To immediately reboot a linux system you can run this command from terminal with root privilege.

    Читайте также:  Как открыть файл dat windows 10

    10. shutdown

    Shutdown command is used to halt or reboot a Linux system. This command has options to schedule shutdown and notify users with custom messages.

    By default, the machine will go down in 1 minute and you can cancel the schedule by issuing shutdown -c

    The system can be shut down immediately by providing ‘now’ option.

    Hardware Related Linux Commands

    These commands are used to view and manage hardware-related aspects of the Linux machine.

    Dmesg command prints its data by reading the kernel ring buffer. The data can be information about the processor, hard disk, printer, keyboard, memory and drivers.

    Displays information on the hardware configuration of the system. Lshw command must be run as root or sudo privileged user otherwise it will only report partial information.

    Displays block device-related information of the machine. Lsblk command with -a you can view all block devices.

    Free command is used in Linux to check the amount of free RAM memory in the system. The free command also shows swap space, buffer and cache space.

    15. lspci

    Lspci is a standard Linux utility that shows what your system’s hardware has got internally. You can expect your results to have information about PCI buses, AGP and onboard components like USB chipset etc.

    16. lsusb

    Lsusb command is used to display information about USB buses in the system and the devices connected to them You can find lsusb utility in usbutils package.

    Dmidecode command reads the system DMI (Desktop Management Interface) table to display hardware and BIOS information of the server. The output of the dmidecode contains several records from the DMI table. This table contains a description of the systems hardware components and also other useful information such as serial number, BIOS revision, etc

    You need root or sudo privilege to run this command. The following examples show the bios details.

    18. hdparm

    Hdparm is a command used in Linux print hard disk information. It can perform disk speed performance and change DMA settings.

    The following command will perform a read speed test on disk sda:

    Statistics Related Linux Commands

    These set of commands are used to view various kinds of stats of the Linux system.

    19. mpstat

    Mpstat command is used to print processor statistics and helps to monitor CPU utilization on your system. It will be more useful if your system has multiple processors.

    20. vmstat

    Vmstat is a tool that provides reporting virtual memory statistics. It covers the system’s memory, swap and processors utilization in real-time.

    By default vmstat print as follows:

    21. iostat

    Iostat command is a command used to monitor the system’s input/output (I/O) device load by observing the time the devices are active in relation to their average transfer rates.

    Tcpdump is a network troubleshooting command which is also known as a packet sniffer is used to capture and display packets from a network. To run tcpdump command you require root or user with sudo privileges.

    When you use tcpdump without any option, it will analyze the traffic on all the interfaces.

    Lsof command stands for ‘List Open Files’. It is extremely useful to find out the details about files that have been opened and their respective processes.

    In order to see the list of files opened by some particular user, use -u option along with lsof commad.

    Linux watch command can be used to repeat a command at regular intervals.

    User Related Linux Commands

    These commands are used to manage Linux users.

    ID command is used in Linux to print real and effective User ID (UID) and Group ID (GID). An UID is a single identity for a user. While Group ID (GID) can consist of more than one UID.

    Linux last command is used to check previously logged in user into your server.

    Who command is a tool print information about users who are currently logged in. who command only see a real user who logged in. It won’t see a user that doing su command (switch user).

    Groupadd command is used to create a group in Linux.

    The following command will add a group ‘developers’ to the system.

    In Linux and Unix-like operating systems, the most common command to create users is ‘useradd’ or ‘adduser’.

    Let’s check how to create a new user ‘bill’ and set a password. The command adds an entry to the /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow files.

    Userdel is a low-level utility for removing users. Userdel command will look for the system account files such as ‘/etc/password’ and ‘/etc/group’ and then it will delete all entries related to the user name from there.

    Linux usermod command is used to modify or change an existing user’s attributes. User’s attributes are home directory, shell, password expiration date, groups, UID etc.

    Passwd is the command used in Linux (Redhat, Centos, Ubuntu, Debian, Fedora) and UNIX-like operating systems to change passwords.

    File Related Linux Commands

    These commands are used to handle files and directories.

    A very simple yet powerful command used for listing files and directories. By default, ls command will list the content of the current directory.

    Linux pwd is a command to print the name of the current working directory. When we are ‘lost’ into a deep directory, we can always reveal where we are.

    Читайте также:  Capture the screen on windows

    Check the example below:

    On Linux, we can use mkdir command to create a directory.

    By default, running mkdir without any option, it will create a directory under the current directory.

    36. cat

    We use cat command mainly to view contents, concatenate and redirect the output of files. The easiest way to use cat is just type ‘cat file_name’.

    The following examples of cat command will display Linux distribution name and which version is currently installed on the hardware.

    When a file no longer needed, we may delete it to save storage space. On the Linux system, we can use rm command to do it.

    Cp command is used in Linux to create copy of files and directories.

    The following command will copy the file ‘myfile.txt’ from current directory to ‘/home/linoxide/office’.

    When you want to move files from one place to another and you don’t want to duplicate it, we use mv command.

    40.cd

    Cd command is used to change the current working directory of a user in Linux and other Unix-like operating systems.

    Symbolic link or soft link is a special type of file that contains a reference, which points to another file or directory. ln command is used to create symbolic links.

    Ln command uses the following syntax:

    Touch command is used in Linux to change for file access and modification time. We may use touch command in Linux to create an empty file.

    More command is a command for displaying a long text file per page at a time.

    The head command is used to print the first few lines of a text file. By default, the head command prints the first 10 lines of each file to standard output, which is the display screen.

    45. tail

    As you may know, cat command is used in displaying the entire content of a file via standard input. But in some cases, we have to print part of the file. By default, the tail command displays the last ten lines.

    GPG is a tool used in linux for secure communication. It uses a combination of two keys (symmetric-key and public-key cryptography) for encrypting files.

    Cksum command is used in Linux print CRC checksum and the number of bytes that are there in that file.

    Diff command is used to compare two files line by line from the terminal.

    Sort command is used in Linux to sort the contents of a text file line by line.

    Uniq is a command line tool used to report and filter duplicate lines from a file.

    Linux wc command counts the number of bytes, characters, words, and lines in a file or in standard input.

    Dir command is used to lists the content of a directory.

    Linux tee command is used for chaining and redirection of tasks, you can redirect the output and/or errors to a file and it will not be shown on the terminal.

    The tr (translate) command is used in Linux mainly for translating and deleting characters. It can be used to convert uppercase to lowercase, squeeze repeating characters and deleting characters.

    Process Related Linux Commands

    These commands are used to handle Linux processes

    55. ps

    Linux ps command is a built-in tool to capture current processes on the system. It will capture the system condition at a single time.

    56. pmap

    The Linux pmap command displays the memory usage map of a process or multiple processes. Pmap reports information about the address space or memory usage map of a process.

    57. top

    The top command in Linux displays the running processes on the system. It is used extensively for monitoring the load on a server.

    58. kill

    The kill command is used on Linux and other Unix-like operating systems to terminate processes without having to log out or reboot the computer.

    59. killall

    The killall command can be used to send a signal to a particular process by using its name. It means if you have five versions of the same program running, the killall command will kill all five.

    60. pkill

    Similar to killall command, pkill send signal to terminate a process with its name. From Centos 7, it encourages to use pkill.

    61. fg and bg

    We can run the jobs in background without any intervention from user. The processes that have been stopped by some interrupt signal can be continued in background with bg command. The fg command is like bg command except that instead of sending a command in the background, it runs them in foreground and occupies the current terminal and waits for process to exit.

    File Permission Related Linux Commands

    These commands are used to change permissions of the files

    The file permissions are applied on three levels: the owner, group members and others. The chmod command is used to change these permissions.

    For following example, 755 will set read+write+execute permission to the user, set read+execute permission to the group and set read+execute permission to others for the file ‘asciiquarium.tar.gz’.

    The chown command in Linux is used to change the ownership and group ownership of files and directories.

    In the following examples the owership of the file ‘/corpora/stopwords/danish.txt’ is change from ‘root:root’ to ‘raghu:altair’.

    Chgrp command is used to changes the group ownership of a file unlike chown command that allows you to change the user and group ownership.

    Читайте также:  Руководство администратора linux г снайдера

    Network Related Linux Commands

    These commands are used to view and edit network configurations related aspects of the system

    The ifconfig command is used to display and set ip address to network interfaces in Linux. Now ifconfig is deprecated in favor of iproute2 (the ip command).

    The linux ip command is similar to ifconfig, but more powerful and is intended to be a replacement for it. With ip you have the advantage of performing several network administration tasks with only one command.

    The ethtool command is used to display/change Ethernet adapter settings. You can change network card speed, auto-negotiation, wake on LAN setting, duplex mode using this tool in Linux.

    Both mii-tool and ethernet tool allows Linux system administrators to modify or change or check the network interface card.

    69. ping and ping6

    Ping and ping 6 commands are used to sends echo requests to the host to test ipv4 and ipv6 connection.

    In Linux whois command is used to g ets information for a domain such as owner of the domain, the owner’s contact information, and nameservers.

    Dig performs DNS lookups and displays the answers that are returned from the name server(s) that were queried.

    Host command is a simple utility for performing DNS lookups in Linux. With this command, we can translate names into IP Addresses and vice versa.

    Wget is the command line, noninteractive, free utility in Unix like Operating systems not excluding Microsoft Windows, for downloading files from the internet.

    Netstat is a command-line tool that is used to view and monitor network statistics and configurations of a system. This tool is available on both Unix, Linux and Windows NT-based operating systems

    Nslookup is a network administration tool for querying the Domain Name System to obtain domain name or IP address from DNS record.

    Compression/Archive Related Commands

    These commands are used to compress and decompress files.

    Tar is a command line tool used to create and manipulate archive files in Linux and Unix systems. Tar command creates .tar archive file and then compress using gzip or bzip2.

    Gzip command compresses files into a single file and suffix ‘.gz’.

    Package Installation Related Commands

    These commands are used to manage Linux packages.

    78. rpm

    RPM (Redhat Package Manager) is a command line package management utility used for installing, uninstalling, updating, querying and verifying software packages.

    79. make

    Make command is used to build executable programs and libraries from source code.

    80. yum

    Yum (Yellowdog Updater Modified) is a utility provided in RHEL based systems to install, remove and search packages. Yum installs the package dependencies automatically, for example, yum install httpd will install ‘apache’ server and it’s required dependencies automatically.

    81. Apt

    Apt is a command line tool for installing, updating, removing deb packages on Ubuntu, Debian, and related Linux distributions.

    Search Related Linux Commands

    These commands are used to search for files and patterns

    The grep command allows searching for a text or string in a file or from output console of a command, for a term or pattern matching regular expressions.

    The locate is a command line utility for searching files and directories in the entire filesystem.

    The Linux find command is a very powerful command which is basically used for searching files under a directory structure using certain criteria.

    SSH is used for logging into a remote machine and for executing commands on a remote machine. Whenever data is sent by a computer to the network, ssh will automatically encrypt.

    Telnet is a command-line tool used to connect remote host manly to test application ports connectivity.

    File Transfer Related Linux Commands

    These commands are used to copy files from one system to another system
    87. scp

    SCP is a secure copy program to transfer files or directories between Linux hosts on the network. SCP uses ssh protocol to transfer the data.

    Here, a local file ‘examples.txt’ is copied to a remote host.

    $ scp examples.txt user@192.168.1.10:/home/user/account

    Rsync synchronizes files and directories between local machines to the remote machine. It can recursively copy files and directory, copy symlinks, preserve (permissions, group, modification time and ownership) file identity.

    Disk Use Related Linux Commands

    These commands are used to view disk statistics.

    The df command displays the disk space usage for the Linux filesystems. It displays the amount of total and free disk space available on the mounted file systems.

    Fdisk command is used in Linux to view the existing partitions, create a new partition, delete or change existing partitions.

    91. du

    The du (disk usage) is the command used in Linux to check the directory size including its other contents as well as the size of individual files.

    The command findmnt is used to list mounted filesystems in Linux. This command will look for a particular filesystem in /etc/fstab, /etc/mtab or /proc/self/mountinfo.

    Mount is a command used in Linux to attached filesystems and drives and umount command is used to detach (unmount) any attached file systems or devices.

    Conclusion

    In this tutorial, we learned an overview of all most all Linux commands. For a final word, you can always rely on Linux man pages for more information. I hope this tutorial was helpful and please provide your suggestions in the below comment section.

    Источник

    Оцените статью