Master Linux: From Installation to Advanced System Management
This guide walks you through Linux fundamentals, installation methods, essential commands, directory and file operations, networking, firewall, package management, MySQL and Tomcat deployment, as well as user, group and scheduled‑task administration, providing practical examples and code snippets for each step.
Why Learn Linux
Windows is commercial, becomes slower over time, and is prone to viruses; Linux is free, open‑source, runs stably for long periods, and virtually has no malware, making it the preferred OS for backend JavaEE developers who need a reliable server environment.
Installation
Linux can be installed directly on a physical PC or inside a virtual machine. Common VM software includes VMWare (paid, trial available) and VirtualBox (free, originally from Sun, now Oracle).
Connecting from Windows to a Linux VM
Use ifconfig or ip addr inside Linux to view IP information, then from Windows run ping www.mobaijun.com to test connectivity.
Client Tools for Remote Access
Popular SSH/Telnet clients are SecureCRT/SecureFX and XShell/XFtp.
Linux Directory Structure
All paths start at the root /. Key directories:
bin : system commands
root : root user’s home
home : regular users’ homes
usr : shared resources, typical install location /usr/local etc : configuration files (e.g., network, permissions)
Directory Operations
Change directory: / – root . – current .. – parent ~ – current user’s home - – previous directory
Create directories: mkdir directory_name Create nested directories: mkdir -p /parent/child List files: ls -l – detailed list ls -a – include hidden files
Search files: find [path] -name "pattern" Rename/Move:
mv old_name new_name # rename mv source_dir target_dir # moveCopy: cp -r source target # recursive copy Delete:
rm -r directory # recursive delete rm -f file # force delete-p creates missing parent directories automatically.
Viewing File Contents
cat filename– full content more filename – paged view head filename – first 10 lines head -n 20 filename – first 20 lines tail filename – last 10 lines tail -n 20 filename – last 20 lines less filename – full view with line numbers, navigation, quit with
qEditing Files with vi/vim
Command mode: i – insert before cursor a – insert after cursor o – open new line below
Common editing commands: yy – yank (copy) current line p – paste after cursor dd – delete current line u – undo /pattern – search forward ( n), backward ( N) wp – write and quit q! – quit without saving
Compression and Extraction
Supported extensions: .zip/.rar – Windows archives .tar – Linux tarball .gz – gzip .tar.gz – tarball compressed with gzip
Create archive: tar -cvzf archive_name.tar.gz file1 file2 ... Extract archive:
tar -xvzf archive_name.tar.gz -C /target/directoryProcess and Memory Management
List processes:
ps -a # all users ps -u # detailed info ps -x # all processesShow memory usage: top Terminate process:
kill -9 PID # force killNetwork Management
Hostname:
# view hostname
hostname
# set hostname permanently
hostnamectl set-hostname new_nameNetwork service control:
systemctl start network
systemctl stop network
systemctl restart network
systemctl status networkStatic IP configuration (CentOS example): edit /etc/sysconfig/network-scripts/ifcfg-ens32 and set ONBOOT=no to disable, ONBOOT=yes to enable, then restart network.
Check ports and listening sockets:
netstat -nutlpFirewall Management (firewalld)
systemctl status firewalld– view status systemctl start firewalld – enable systemctl stop firewalld – disable systemctl enable firewalld – start on boot systemctl disable firewalld – prevent auto‑start
SSH Key‑Based Login
# generate key pair
ssh-keygen
# copy public key to remote host
ssh-copy-id user@host
# test password‑less login
ssh user@hostPackage Management (RPM & YUM)
RPM common options: -v – verbose -q – query -a – list all packages -i – install --nodeps – ignore dependencies (used with -e to force uninstall)
Example queries:
rpm -qa # list all installed packages
rpm -ivh package.rpm # install
rpm -e --nodeps package.rpm # force uninstallChange YUM source (CentOS 7):
yum install -y wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
vim /etc/yum.repos.d/CentOS-Base.repo # replace http with https
yum updateMySQL Installation and Remote Access
# check existing MySQL
rpm -qa | grep mysql
# download repo package
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
# install client, server, tools
yum -y install mysql-community-client mysql-community-server mysql-community-devel
# start and enable service
systemctl start mysqld
systemctl enable mysqld
# set root password
mysql -uroot -e "SET PASSWORD = PASSWORD('root');"
# enable remote login
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root'; FLUSH PRIVILEGES;"
# open firewall port 3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalldTomcat Deployment
# upload and extract
tar -xvf apache-tomcat-8.5.55-src.tar.gz -C /usr/local/
mv apache-tomcat-8.5.55-src tomcat8
cd /usr/local/apache-tomcat-8.5.55-src/bin
chmod u+x *.sh
./startup.sh # start Tomcat
# open firewall for port 8080
firewall-cmd --zone=public --add-port=8080/tcp --permanent
systemctl restart firewalld
# if JAVA_HOME missing, edit setclasspath.sh
export JAVA_HOME=/usr/local/jdk1.8.0_251
export JRE_HOME=$JAVA_HOME/jreProject Publishing
Import database, build a WAR in IDEA, copy the WAR to /usr/local/tomcat8/webapps, then restart Tomcat with shutdown.sh and startup.sh. Fix MySQL charset by adding ?characterEncoding=utf8 to the JDBC URL in druid.properties.
User and Group Management
# add user and home directory
useradd -m mobaijun
# set password
passwd mobaijun
# switch user
su mobaijun
# delete user and its group
userdel -r tom
# modify login name
usermod -l Rose mobaijun
# add group
groupadd dev
# add user to group
usermod -g dev mobaijun
# remove user from group
gpasswd -d mobaijun dev
# rename group
groupmod -n newdev dev
# delete group
groupdel newdevGrant sudo privileges by editing /etc/sudoers and adding appropriate entries.
Scheduled Tasks (crontab)
crontab -l # list current jobs
crontab -e # edit jobs
crontab -r # remove all jobs
* * * * * command # run every minuteAdditional Tools
Use netstat -nutlp to view listening ports, ssh-keygen for key generation, and ping to test connectivity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
