Master Linux System Basics: Time, Hostname, Users, Network & Process Commands
This guide provides a comprehensive overview of essential Linux system administration tasks, covering how to view and set system time, manage hostnames, inspect kernel information, handle user and group files, use common network utilities, monitor disk usage, and track processes with tools like top and ps.
Introduction
The purpose of this article is to give readers a complete basic understanding of Linux systems, covering common information and configuration tasks for network, system, CPU, memory, disks, and processes.
Linux System Time
View the current system time:
<code>date</code>Set the system time:
<code>date -s "2016-02-09 15:15:00"</code>Synchronize network time using NTP:
<code>ntpdate -u ntp.api.bz</code>Note: NTP synchronizes the local clock with remote servers such as 210.72.145.44, ntp.api.bz, time.nist.gov, etc. Only the root user can change the system time, and after setting it you should run
clock -wto write the time to CMOS.
Hostname and OS Information
Display the system hostname:
<code>hostname</code>To permanently change the hostname, edit
/etc/hostnameand
/etc/sysconfig/network, then reboot.
Show kernel and OS details with
uname:
<code>uname -a</code>Key fields: kernel name, hostname, kernel version, hardware name, processor type, hardware platform, OS name.
Common
unameoptions:
-mor
--machine: hardware (CPU) name
-nor
--nodename: network node name
-ror
--release: kernel release
-sor
--sysname: kernel name
-v: kernel version
-p: processor type
-i: hardware platform
-o: operating system
User and Group Management
User and group classification includes local accounts, remote (domain) accounts, LDAP, NIS, and system vs. regular users. Configuration files:
/etc/passwd: user account information
/etc/shadow: encrypted passwords
/etc/group: group information
/etc/gshadow: group passwords
Example of a
/etc/passwdline:
<code>root:x:0:0:root:/root:/bin/bash</code>Fields: username, password placeholder, UID, GID, description, home directory, login shell.
Example of a
/etc/shadowline:
<code>root:$6$zVDR2oO1Yg7alTbs$.70PPMYxg70k9BvLtjHdm94CDA1YWDRDI5NFzSfcmZF5WMESgIbLUdnqRjuVycg481Ny9rl//YzAFnXhurQi//::0:99999:7:::</code>Fields include encrypted password, last password change date, minimum days before change, maximum days before expiration, warning period, etc.
Adding a user:
<code>useradd zhanglonghao</code>Common
useraddoptions:
-ccomment
-dhome directory
-eaccount expiration date
-fdays after expiration before disabling
-gprimary group
-Gsupplementary groups
-mcreate home directory
-rcreate system account
-slogin shell
-uUID
Modifying a user:
<code>usermod -u 1005 zhanglonghao</code>Deleting a user (optionally remove home files):
<code>userdel -rf zhanglonghao2</code>Basic Network Operations
Fetch a web page with
curl:
<code>curl www.baidu.com</code>Download a file with
wget:
<code>wget http://download.redis.io/releases/redis-3.0.6.tar.gz</code>Text‑based browsers:
<code>w3m www.baidu.com</code> <code>links www.baidu.com</code>Check connectivity with
ping:
<code>ping www.baidu.com</code>Trace network paths with
mtr(example options shown):
<code>mtr -r -c 30 www.baidu.com</code>DNS lookup with
host:
<code>host www.baidu.com</code>Network Interface Configuration
Display interfaces with
ifconfig:
<code>ifconfig</code>Modern
ipcommands:
<code>ip link show</code> <code>ip -s link show</code> <code>ip addr show</code>Network Monitoring Tools
Show active connections with
netstat(common options):
<code>netstat -a</code> <code>netstat -at</code> <code>netstat -au</code> <code>netstat -ant</code> <code>netstat -tnl</code> <code>netstat -nlpt</code>Real‑time traffic monitoring with
iftop(install first). Common options include
-ito select interface,
-Bfor bytes,
-nto show IPs,
-Nto show ports, etc.
Disk Usage and Tree View
Show filesystem usage:
<code>df -h</code>Show directory sizes:
<code>du --max-depth=1 -h</code>Tree view of directories (example):
<code>tree -L 3 src</code>Process Monitoring
Interactive process viewer
top(default refresh 3 s). Common keys:
Spacerefresh,
qquit,
Msort by memory,
Psort by CPU.
List processes with
ps(BSD style):
<code>ps -aux</code>Tree view of processes:
<code>pstree -p</code>Memory Information
Show memory summary:
<code>free -h</code>Detailed memory info from
/proc/meminfo:
<code>cat /proc/meminfo</code>Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.