Open main menu

CDOT Wiki β

Changes

OPS102 - File Globbing, Common Commands, Text Editors

3,366 bytes added, 05:47, 18 September 2023
no edit summary
{|cellspacing="0" width="100%" cellpadding="5" border="1" style="background: #ffffff"
|-
!Symbol!!Meaning in Linux!!Meaning in Windows
|-
{|cellspacing="0" width="100%" cellpadding="5" border="1" style="background: #ffffff"
|-
!Pattern!!Matches on Linux!!Does not match on Linux!!Matches on Windows!!Does not match on Windows
|-
|a??||aaa abc||aa abcd||aaa abc aa||abcd
|}
 
Therefore the command
 
del *.pdf
 
on Windows, or
 
rm *pdf
 
on Linux will remove all files with the extension <code>.pdf</code>
 
== Common Basic Commands ==
 
Here are some basic commands useful for managing the filesystem and performing basic tasks:
 
{|cellspacing="0" width="100%" cellpadding="5" border="1" style="background: #ffffff"
!Linux!!Windows!!Description
|-
|ls||dir||Displays the contents of a directory -- by default, the current directory, or the directories specified as arguments (or a specific file, if specified).
|-
|echo||echo||Places a message on the screen (the message is given as positional arguments)
|-
|cal|| ||Displays a simple calendar
|-
|date||date /t<br />time /t||Displays the date/time
|-
|who||quser||Displays information about the logged in user(s)
|-
|whoami||whoami||Displays the name of the current user
|-
|cls||clear||Clears the terminal display
|-
|tree||tree||Displays the filesystem hierarchy starting at the current directory (or the given directory, if an argument is provided).
|-
|mkdir||mkdir||Creates a directory/folder
|-
|rmdir||rmdir||Removes a directory/folder
|-
|rm||del||Removes/deletes one or more files. Specify <code>-rf</code> to recursively force delete a directory and its contents on Linux, or <code>/s</code> to recursively delete a directory and its contents on Windows.
|-
|cd||cd||Changes to the given directory, if one is given. If no directory is given, displays the current directory (Windows) or changes to your home directory (Linux). On Windows, a drive designator may be provided, in which case the current directory will be set on the indicated drive.
|-
| ||X:||(Where X is a drive designator) Switches to the selected drive.
|-
|pwd|| ||Prints the current working directory.
|-
|cp||copy||Copy one or more files to a new name/location.
|-
|mv||move||Moves a file from one directory to another.
|-
|mv||ren<br>rename||Renames a file (on Linux, the filename and location are considered to be the same thing)
|-
|cat||type||Dumps the contents of a text file on the terminal (if there is a lot of text, the display will scroll; if the file is a non-text file, the results are undefined!)
|-
|more<br>less||more||Displays a file one screen at a time. (Linux: the less command is a more powerful version of the <code>more</code> command, which allows things like scrolling backwards)
|-
|cut|| ||Selects specific columns from a text file
|-
|sort||sort||Sorts a text file
|-
|diff||comp||Shows the differences between (text) files
|-
|uniq|| ||Displays identical consequtive lines only once
|-
|tr|| ||Translates/replaces/deletes occurrences of characters
|-
|grep||find||Searches files for text
|-
|find|| ||Searches for files
|-
|touch||copy NUL: ''filename''||Creates an empty file (Linux: if the file exists, <code>touch</code> will just update the date/time of modification).
|}
 
To view information about a Linux command, use the online manual ("manpages"), accessed with the <code>man</code> command:
 
man ''commandname''
 
For example, to view the online manual page for <code>cp</code>, enter the command:
 
man cp
 
On Windows, you can see a list of commonly used commands by typing
 
help
 
To get a brief help summary for a command, enter the name of the command followed by <code>/?</code> -- for example, to get a help summary for the <code>copy</code> command, type
 
copy /?