Common Linux Commands
From WikiHack
This is a list of common Linux and bash shell commands, ranging from basic navigation/editing to drive overhaul to security hardening.
Contents |
[edit]
Basic Commands
[edit]
man
shows a manual page for a program
- $ man bzip2 - shows the bzip2 help page.
[edit]
Navigation
[edit]
cd
Changes directory to that specified.
- $ cd - returns to the user's home directory.
- $ cd /etc - moves to the /etc directory.
- $ cd foo - moves to the foo directory within the current one.
- $ cd ~ - returns to the user's home directory.
- $ cd .. - move to the parent directory of the one you are in.
[edit]
ls
Lists the contents of a directory.
- $ ls - lists the contents of the current directory.
- $ ls /usr/local - lists the contents of the /usr/local directory.
- $ ls -l foo - lists the contents of foo with permission information.
- $ ls -l -h foo - lists the contents of foo with permission information, and outputs size information in human-readable form.
- $ ls -a foo - lists all the files in foo, including hidden ones.
[edit]
pwd
Outputs the directory the user is currently working in.
[edit]
File and Disk Management
[edit]
mv
Moves a file or directory from one place to another.
- $ mv foo.bar /etc/ - Moves foo.bar, located in the working directory, to /etc/foo.bar
- $ mv foo.bar foo2.bar - Renames foo.bar to foo2.bar
- $ mv -v foo/ /etc/ - Moves the directory foo/ to /etc/foo/ with verbose output
[edit]
cp
Copies a file from one location to another.
[edit]
rm
Removes a file from the system.
[edit]
Process Management
[edit]
User Groups and Privileges
[edit]
passwd
Changes the password for the current user
[edit]
chpasswd
Root-only method for changing passwords of other users
[edit]
Networking
[edit]
ifconfig
Configures a network interface
- $ ifconfig - Displays all network card information for all interfaces
- $ ifconfig eth0 - Displays all network card information for the eth0 interface
[edit]
iwconfig
Configures a wireless network interface
- $ iwconfig - Displays all wireless extension information for all interfaces
- $ ifconfig wlan0 - Displays all wireless extension information for the wlan0 interface
[edit]
Basic System Administration
[edit]
shutdown
Controls the shutting down of a system.
- # shutdown -h now - Shuts down the system and halts it (powers off) immediately
- # shutdown -r now - Shuts down the system and reboots the system immediately

