Purnell78

Sign In

Useful Linux Commands Print E-mail
Written by George Taylor   
Tuesday, 08 July 2008 18:37

This list of commands work on Debian 4.0 and most Unix based systems. If a particular command doesn't exist for your distro there is likely an equivalent available.

Linux Penguin[command] | less – is a program similar to more, but which allows backward movement in the file as well as forward movement.

[command] | more – is a filter for paging through text one screenful at a time.

apt-cache search [string] – performs a full text search on all available package lists.

apt-get – a command-line tool for handling packages.

  • apt-get install [package name] [package name] ….. – use to install one or more packages.
  • apt-get remove [package name] [package name] ….. – use to remove one or more packages.
  • apt-get update – resynchronizes the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list.
  • apt-get upgrade – installs the newest versions of all packages currently installed on the system from the sources in /etc/apt/sources.list.

cat [filename] – outputs file contents.

cd – change to home directory.

  • cd / – change to root directory.
  • cd [directory name] – change directory.
  • cd.. – go up one step of the directory tree.

cp [filename] [filename] … [destination] – copy files

dir – list directory contents.

dmesg – outputs bootup messages.

init – process control initialization.

  • init 6 – Reboot: works on the majority of Unix based systems.

kill [-signal] [PID] – send a kill signal to a process. See ps.

  • term - signal may be blocked by process
  • stop - signal can not be blocked by process

locate – list files in databases that match a pattern; use to find files quickly that have already been indexed. See updatedb.

ls – list directory contents

  • ls -l – use a long listing format; displays permissions, user & group owner, etc..
  • ls -ltr – sorts by modification time in reverse order, so that last modified is displayed last; useful for founding new messages in log files.

man [command] – an interface to the on-line reference manuals.

  • man -k [string] – searches for string in command name and description.

mkdir [string] – create a new directory.
mv – move or rename files or directories.

  • mv [old filename] [new filename] – rename files
  • mv [string] [string] … [destination] – move files or directories.

nano – file editor

ps – report a snapshot of the current processes

  • ps -eaf – list system process

rm [string] – delete a file.

  • rm -r [string] – delete a non-empty directory.

rmdir [string] – delete an empty directory.

screen – is a full-screen window manager that multiplexes a physical terminal between several processes

  • Ctrl + A + : title [string] – give active terminal a title
  • Ctrl + A + ? – list commands for screen
  • Ctrl + A + “ – list active terminals
  • Ctrl + A + C – create new terminal
  • Ctrl + A + D – detach session; used to enable a terminal to be closed and detached session

touch [string] – create a new file.

updatedb – updates file name database. (Note: updatedb runs as a cron job once a day.)

Tips

Double "Tab" to Save Time.
Hit the “Tab” key to complete spelling of commands or directory paths. Double “Tab” to get a list of possible commands. For example, if you type “net” and then double type you will get a list of commands that start with net: netcat, netkit-ftp, netstat, etc...

Kill Current Process
Crtl + C – Kills current process

Redirecting
Redirection is good to create files made from the output of a command. Of course, there are many other applications.

dmesg > bootmesg.txt

The command would create a file named bootmesg.txt and place the output of dmesg into it. If you would like to append the output of the command to dmesg to bootmesg.txt simply use >>.

dmesg >> bootmesg.txt

 

Add your comment

Your name:
Your website:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification: