Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

4.3.2 Basic Unix commands

Let's learn the basic Unix commands. [ 20] Try all the following commands from the non-privileged user account penguin :

  • pwd

    • Display name of current/working directory.

  • whoami

    • Display current user name.

  • file foo

    • Display a type of file for the file foo.

  • type -p commandname

    • Display a file location of command commandname.

    • which commandname does the same. [21]

  • type commandname

    • Display information on command commandname.

  • apropos key-word

    • Find commands related to key-word.

    • man -k key-word does the same.

  • whatis commandname

    • Display one line explanation on command commandname.

  • man -a commandname

    • Display explanation on command commandname. (Unix style)

  • info commandname

    • Display rather long explanation on command commandname. (GNU style)

  • ls

    • List contents of directory. (non-dot files and directories) [22]

  • ls -a

    • List contents of directory. (all files and directories)

  • ls -A

    • List contents of directory. (almost all files and directories, i.e., skip ".." and ".")

  • ls -la

  • ls -d

    • List all directories under the current directory.

  • lsof foo

    • List open status of file foo.

  • mkdir foo

    • Make a new directory foo in the current directory.

  • rmdir foo

    • Remove a directory foo in the current directory.

  • cd foo

    • Change directory to the directory foo in the current directory or in the directory listed in the variable CDPATH. See cd command in builtins(7).

  • cd /

    • Change directory to the root directory.

  • cd

    • Change directory to the current user's home directory.

  • cd /foo

    • Change directory to the absolute path directory /foo.

  • cd ..

    • Change directory to the parent directory.

  • cd ~foo

    • Change directory to the home directory of the user foo.

  • cd -

    • Change directory to the previous directory.

  • </etc/motd pager

  • touch junkfile

    • Create a empty file junkfile.

  • cp foo bar

    • Copy a existing file foo to a new file bar.

  • rm junkfile

    • Remove a file junkfile.

  • mv foo bar

    • Rename an existing file foo to a new name bar.

  • mv foo bar/baz

    • Move an existing file foo to a new location with a new name bar/baz. The directory bar must exist.

  • chmod 600 foo

    • Make an existing file foo to be non-readable and non-writable by the other people. (non-executable for all)

  • chmod 644 foo

    • Make an existing file foo to be readable but non-writable by the other people. (non-executable for all)

  • chmod 755 foo

    • Make an existing file foo to be readable but non-writable by the other people. (executable for all)

  • top

    • Display process information using full screen. Type "q" to quit.

  • ps aux | pager

  • ps -ef | pager

    • Display information on all the running processes using Unix system-V style output.

  • ps aux | grep -e "[e]xim4*"

    • Display all processes running exim or exim4. Learn the regular expression from grep(1) manual page by typing man grep. [ 24]

  • ps axf | pager

    • Display information on all the running processes with ASCII art output.

  • kill 1234

  • grep -e "pattern" *.html

    • Find a "pattern" in all of the files ending with .html in current directory and display them all.

  • gzip foo

    • Compress foo to create foo.gz using the Lempel-Ziv coding (LZ77).

  • gunzip foo.gz

    • Decompress foo.gz to create foo.

  • bzip2 foo

    • Compress foo to create foo.bz2 using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. (Better compression than gzip)

  • bunzip2 foo.bz2

    • Decompress foo.bz2 to create foo.

  • tar -xvvf foo.tar

    • Extract files from foo.tar archive.

  • tar -xvvzf foo.tar.gz

    • Extract files from gzipped foo.tar.gz archive.

  • tar -xvvf --bzip2 foo.tar.bz2

    • Extract files from foo.tar.bz2 archive. [25]

  • tar -cvvf foo.tar bar/

    • Archive contents of folder bar/ in foo.tar archive.

  • tar -cvvzf foo.tar.gz bar/

    • Archive contents of folder bar/ in compressed foo.tar.gz archive.

  • tar -cvvf --bzip2 foo.tar.bz2 bar/

    • Archive contents of folder bar/ in foo.tar.bz2 archive. [ 26]

  • zcat README.gz | pager

    • Display contents of compressed README.gz using the default pager.

  • zcat README.gz > foo

    • Create a file foo with the decompressed content of README.gz.

  • zcat README.gz >> foo

    • Append the decompressed content of README.gz to the end of the file foo. (If it does not exist, create it first.)

  • find . -name pattern

    • find matching filenames using shell pattern. (slower)

  • locate -d . pattern

    • find matching filenames using shell pattern. (quicker using regularly generated database)

Please traverse directories and peek into the system using above commands as a training. If you have questions on any of the console commands, please make sure to read the manual page. For example, these commands are the good start:

     $ man man
     $ man bash
     $ man ls

Also this is a good timing to start vim and press F1-key. You should at least read the first 35 lines. Then do the online training course by moving cursor to |tutor| and pressing Ctrl-]. See Editors, Chapter 11 to learn more about editors.

Please note that many Unix-like commands including ones from GNU and BSD will display brief help information if you invoke them in one of the following ways (or without any arguments in some cases):

     $ commandname --help
     $ commandname -h

Try also examples in Debian tips, Chapter 8 as your self training.


Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire