Common Linux Commands

From WikiHack

Jump to: navigation, search

This is a list of common Linux and bash shell commands, ranging from basic navigation/editing to drive overhaul to security hardening.

Contents

Basic Commands

man

shows a manual page for a program

$ man bzip2 - shows the bzip2 help page.

Navigation

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.

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.

pwd

Outputs the directory the user is currently working in.

File and Disk Management

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

cp

Copies a file from one location to another.

rm

Removes a file from the system.

Process Management

User Groups and Privileges

passwd

Changes the password for the current user

chpasswd

Root-only method for changing passwords of other users

Networking

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

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

Basic System Administration

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
Personal tools