Difference between revisions of "This Is Your Brain On Informatics: Linux Commands"

From Pathology Education Instructional Resource
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
===General Linux Command Info===
 
===General Linux Command Info===
 
 
*Almost every single command should have an argument (an input for a function)
 
*Almost every single command should have an argument (an input for a function)
 
*A filename in Linux refers to both a file's name and a directory's name
 
*A filename in Linux refers to both a file's name and a directory's name
 
  
 
===Common Linux Commands===
 
===Common Linux Commands===
 
 
{| class="wikitable"
 
{| class="wikitable"
 +
|-
 +
! style="padding: 10px;"| Command
 +
! style="padding: 10px;"| Syntax
 +
! style="padding: 10px;"| Description
 
|-
 
|-
! Command
+
| style="padding: 10px;"| cat
! Syntax
+
| style="padding: 10px;"| cat ''filename''
! Description
+
| style="padding: 10px;"| Display file’s contents to the standard output device (usually your monitor)
 
|-
 
|-
| cat
+
| style="padding: 10px;"| cd
| cat ''filename''
+
| style="padding: 10px;"| cd ''/pathname''
| Display file’s contents to the standard output device (usually your monitor)
+
| style="padding: 10px;"| Change to the given directory
 
|-
 
|-
| cd
+
| style="padding: 10px;"| chmod*
| cd ''/pathname''
+
| style="padding: 10px;"| chmod ''options'' ''mode'' ''filename''
| Change to the given directory
+
| style="padding: 10px;"| Changes a file's permissions.
 
|-
 
|-
| chmod*
+
| style="padding: 10px;"| chown
| chmod ''options'' ''mode'' ''filename''
+
| style="padding: 10px;"| chown ''private_owner:group_owner'' ''filename''
| Changes a file's permissions.
+
| style="padding: 10px;"| Changes ownership of the file
 
|-
 
|-
| chown
+
| style="padding: 10px;"| clear
| chown ''private_owner:group_owner'' ''filename''
+
| style="padding: 10px;"| clear
| Changes ownership of the file
+
| style="padding: 10px;"| Clears the screen by scrolling (does not delete anything)
 
|-
 
|-
| clear
+
| style="padding: 10px;"| cp
| clear
+
| style="padding: 10px;"| cp ''options'' ''source'' ''destination''
| Clears the screen by scrolling (does not delete anything)
+
| style="padding: 10px;"| Copies a file from the source to the destination
 
|-
 
|-
| cp
+
| style="padding: 10px;"| find
| cp ''options'' ''source'' ''destination''
+
| style="padding: 10px;"| find ''/pathname'' ''string''
| Copies a file from the source to the destination
+
| style="padding: 10px;"| Starts at the indicated directory and searches for the string in a filename
 
|-
 
|-
| find
+
| style="padding: 10px;"| grep
| find ''/pathname'' ''string''
+
| style="padding: 10px;"| grep ''options'' ''pattern'' ''filename''
| Starts at the indicated directory and searches for the string in a filename
+
| style="padding: 10px;"| Searches for the pattern in the file
 
|-
 
|-
| grep
+
| style="padding: 10px;"| ifconfig
| grep ''options'' ''pattern'' ''filename''
+
| style="padding: 10px;"| ifconfig
| Searches for the pattern in the file
+
| style="padding: 10px;"| Displays the current networks available and various information about them
 
|-
 
|-
| ifconfig
+
| style="padding: 10px;"| ll
| ifconfig
+
| style="padding: 10px;"| ll ''/pathname''
| Displays the current networks available and various information about them
+
| style="padding: 10px;"| List Long:  lists the details of the entire directory or file indicated
 
|-
 
|-
| ll
+
| style="padding: 10px;"| ln
| ll ''/pathname''
+
| style="padding: 10px;"| ln ''options'' ''source'' ''destination''
| List Longlists the details of the entire directory or file indicated
+
| style="padding: 10px;"| Link:  creates a shortcut. Use -s for the ''options'' to create a soft link (more capabilities)
 
|-
 
|-
| ln
+
| style="padding: 10px;"| ls
| ln ''options'' ''source'' ''destination''
+
| style="padding: 10px;"| ls ''/pathname''
| Link: creates a shortcut.  Use -s for the ''options'' to create a soft link (more capabilities)
+
| style="padding: 10px;"| Lists the files and directories in a given directory
 
|-
 
|-
| ls
+
| style="padding: 10px;"| man
| ls ''/pathname''
+
| style="padding: 10px;"| man ''command''
| Lists the files and directories in a given directory
+
| style="padding: 10px;"| Opens the manual page for the given command
 
|-
 
|-
| man
+
| style="padding: 10px;"| mkdir
| man ''command''
+
| style="padding: 10px;"| mkdir ''options'' ''filename''
| Opens the manual page for the given command
+
| style="padding: 10px;"| Makes a directory at the given location with the given name
 
|-
 
|-
| mkdir
+
| style="padding: 10px;"| mv
| mkdir ''options'' ''filename''
+
| style="padding: 10px;"| mv ''options'' ''source'' ''destination''
| Makes a directory at the given location with the given name
+
| style="padding: 10px;"| Moves a file or directory from the source to the destination
 
|-
 
|-
| mv
+
| style="padding: 10px;"| [[This Is Your Brain On Informatics: Pico|pico]]
| mv ''options'' ''source'' ''destination''
+
| style="padding: 10px;"| pico ''filename''
| Moves a file or directory from the source to the destination
+
| style="padding: 10px;"| Opens the given file in the pico text editor
 
|-
 
|-
| [[This Is Your Brain On Informatics: Pico|pico]]
+
| style="padding: 10px;"| pwd
| pico ''filename''
+
| style="padding: 10px;"| pwd
| Opens the given file in the pico text editor
+
| style="padding: 10px;"| Displays the pathname for the current directory
 
|-
 
|-
| pwd
+
| style="padding: 10px;"| rm
| pwd
+
| style="padding: 10px;"| rm ''options'' ''filename''
| Displays the pathname for the current directory
+
| style="padding: 10px;"| Removes the given file.  If -rf is used for the options, a directory and its roots will be removed as well
 
|-
 
|-
| rm
+
| style="padding: 10px;"| ssh
| rm ''options'' ''filename''
+
| style="padding: 10px;"| ssh ''options'' ''user@machine''
| Removes the given file.  If -rf is used for the options, a directory and its roots will be removed as well
+
| style="padding: 10px;"| Remotely logs into the given machine with the given user name
 
|-
 
|-
| ssh
+
| style="padding: 10px;"| sudo
| ssh ''options'' ''user@machine''
+
| style="padding: 10px;"| sudo ''command''
| Remotely logs into the given machine with the given user name
+
| style="padding: 10px;"| Allows super user privileges for the given command (requires root password).  sudo su allows login to root
 
|-
 
|-
| sudo
+
| style="padding: 10px;"| tar
| sudo ''command''
+
| style="padding: 10px;"| tar -xzvf ''filename''
| Allows super user privileges for the given command (requires root password). sudo su allows login to root
+
| style="padding: 10px;"| Extracts files with the extension *.tar.gz or *.tgz
 
|-
 
|-
| tar
+
| style="padding: 10px;"| touch
| tar -xzvf ''filename''
+
| style="padding: 10px;"| touch ''filename''
| Extracts files with the extension *.tar.gz or *.tgz
+
| style="padding: 10px;"| Creates an empty file with given name
 
|-
 
|-
| touch
+
| style="padding: 10px;"| wget
| touch ''filename''
+
| style="padding: 10px;"| wget ''internet address''
| Creates an empty file with given name
+
| style="padding: 10px;"| Downloads a file from a given internet address
|-
 
| wget
 
| wget ''internet address''
 
| Downloads a file from a given internet address
 
 
|-
 
|-
  
Line 109: Line 106:
  
 
===*Notes on chmod===
 
===*Notes on chmod===
 
 
'''chmod''' has several input options.  Using a "+" and an "r", "w", and/or "x" will add read, write, or execute permissions respectively to the given file.  A "-" will take these away.  The other system is a binary system in which there are permissions for the private user, the group, and the public (other) given as 000 000 000 where each set of three 0's equals the private user, group, or public respectively.  The first 0 in each set of 0's is for reading permission, the second for writing, and the third for executing.  Because it is binary 100 000 000 (permission for the private user to read only) will be written as 400 in the command line (after translating the binary to decimal where 100 = 4)
 
'''chmod''' has several input options.  Using a "+" and an "r", "w", and/or "x" will add read, write, or execute permissions respectively to the given file.  A "-" will take these away.  The other system is a binary system in which there are permissions for the private user, the group, and the public (other) given as 000 000 000 where each set of three 0's equals the private user, group, or public respectively.  The first 0 in each set of 0's is for reading permission, the second for writing, and the third for executing.  Because it is binary 100 000 000 (permission for the private user to read only) will be written as 400 in the command line (after translating the binary to decimal where 100 = 4)
  
  
 +
{{This Is Your Brain On Informatics}}
  
{{This Is Your Brain On Informatics}}
+
[[Category:This Is Your Brain On Informatics]]

Latest revision as of 00:57, 27 March 2014

General Linux Command Info

  • Almost every single command should have an argument (an input for a function)
  • A filename in Linux refers to both a file's name and a directory's name

Common Linux Commands

Command Syntax Description
cat cat filename Display file’s contents to the standard output device (usually your monitor)
cd cd /pathname Change to the given directory
chmod* chmod options mode filename Changes a file's permissions.
chown chown private_owner:group_owner filename Changes ownership of the file
clear clear Clears the screen by scrolling (does not delete anything)
cp cp options source destination Copies a file from the source to the destination
find find /pathname string Starts at the indicated directory and searches for the string in a filename
grep grep options pattern filename Searches for the pattern in the file
ifconfig ifconfig Displays the current networks available and various information about them
ll ll /pathname List Long: lists the details of the entire directory or file indicated
ln ln options source destination Link: creates a shortcut. Use -s for the options to create a soft link (more capabilities)
ls ls /pathname Lists the files and directories in a given directory
man man command Opens the manual page for the given command
mkdir mkdir options filename Makes a directory at the given location with the given name
mv mv options source destination Moves a file or directory from the source to the destination
pico pico filename Opens the given file in the pico text editor
pwd pwd Displays the pathname for the current directory
rm rm options filename Removes the given file. If -rf is used for the options, a directory and its roots will be removed as well
ssh ssh options user@machine Remotely logs into the given machine with the given user name
sudo sudo command Allows super user privileges for the given command (requires root password). sudo su allows login to root
tar tar -xzvf filename Extracts files with the extension *.tar.gz or *.tgz
touch touch filename Creates an empty file with given name
wget wget internet address Downloads a file from a given internet address

*Notes on chmod

chmod has several input options. Using a "+" and an "r", "w", and/or "x" will add read, write, or execute permissions respectively to the given file. A "-" will take these away. The other system is a binary system in which there are permissions for the private user, the group, and the public (other) given as 000 000 000 where each set of three 0's equals the private user, group, or public respectively. The first 0 in each set of 0's is for reading permission, the second for writing, and the third for executing. Because it is binary 100 000 000 (permission for the private user to read only) will be written as 400 in the command line (after translating the binary to decimal where 100 = 4)