Programmer's Wiki
Advertisement
This page needs cleanup.

Linux provides a command-line interface. To be able to use it properly you need to know what commands to use. Linux commands are case-sensitive.

List of commands[]

The following is a list of linux commands.

sudo[]

Sudo stands for substitute user do and can be used to execute a single command as root.

sudo <command>

for instance to copy a file as root, type:

sudo cp <file> <new file>

File Management[]

ls[]

list lists files (and subdirectories) in the provided path name. If no path name is applied, the files of the current directory will be listed instead.

ls <path>

cp[]

Copies files.

cp <path to file> <path to file in new directory>

mv[]

moves a file to a new directory. This command is also commonly used to rename files, by giving the same directory as the second parameter but with another file name.

mv <path to file> <path to file in new directory>

rm[]

The rm command is used for removing file(s). Syntax:

rm <path>

chmod[]

chmod is used for changing the permissions of a file.[]

chmod <permission model> <file name and path>

Process Management[]

Killall[]

The killall command kills all PID's with the parameter as their name.

killall <process name>

Package Management[]

Debian based systems[]

Debian-based systems use apt-get for installing packages from a repository and dpkg for installing local deb files.

apt-get[]

Use the apt-get command to install packages from remote repositories. Must be run as root.

sudo apt-get <option> <package name>

To install a package use install as parameter, to remove/uninstall a package use remove as parameter. Additional options include:

  • apt-get update to update the package list
  • apt-get --reinstall install <package name> to reinstall a package
dpkg[]

dpkg allows installation of local packages. The most common parameter is -i for installing software. dpkg has to be run as root.

sudo dpkg -i <path to local package>

RPM based systems[]

RPM based systems use the Yum command for both installing packages from repositories as well as for local packages, or rpm files.

grep[]

grep prints out the lines in a file or standard input that match a specified regular expression

Eg:

grep "html" sample.html

sed[]

sed is a command that can perform many line editing operations such as

  • search and replace
  • line deletion

etc

more/less[]

command that displays files on the screen.

more <filename> or less <filename>

scp[]

Secure copy is a command that allows you to copy files remotely from another machine.

whoami[]

The whoami command outputs the name of the current user.

echo[]

The echo command outputs the text used as parameters, IE echo "Hello World!" would output Hello World!

md5sum[]

Returns the md5 checksum of <file>

md5sum <file>

cat[]

cat is used to return the contents of a file. <file> is the pathname of the file to print the contents of.

cat <file>

Example:

cat > file1.txt

Advertisement