basic_linux_commands.md 6.21 KB
Newer Older
Adam Caprez's avatar
Adam Caprez committed
1
2
3
4
5
+++
title = "Basic Linux commands"
description = "Simple commands you'll want to know"
weight = "32"
+++
6

Adam Caprez's avatar
Adam Caprez committed
7
8
Basic commands
--------------
9

Adam Caprez's avatar
Adam Caprez committed
10
###### [[Jump to the Video Tutorial]](#tutorial-video)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

Holland clusters all run on the Linux operating system, similarly to how
your personal computer might run Windows or Mac OS. However, unlike
Windows or Mac OS, our systems do not utilize a graphical user interface
where you can use a mouse to navigate and initiate commands. Instead, we
use a command line interface, where the user types in commands which are
then processed and text output is displayed on the screen. The default
shell used is Bash. Bash may seem complicated to learn at first, but
with just a small handful of commands, you can do anything that you
would usually do with a mouse. **In fact, once people become proficient
in Bash, many of them prefer it over graphical interfaces due to its
versatility and performance.**

Below, we have compiled a list of common commands and usage examples.
For a more information, check out one of these references:

Adam Caprez's avatar
Adam Caprez committed
27
28
29
30
31
32
-  [Software Carpentry’s "Introduction to the Bash Shell" Lesson](https://eharstad.github.io/shell-novice) - 
   a great walkthrough of the basics of Bash designed for novice users
-  [Linux Users Guide](http://www.comptechdoc.org/os/linux/usersguide) -
   detailed information about the Linux command line and how to utilize
   it
-  [Linux Command Line Cheat Sheet](https://www.cheatography.com/davechild/cheat-sheets/linux-command-line) -
33
34
35
36
37
38
39
40
41
42
43
44
45
    a quick reference for Linux commands. Offers a PDF version that you
    can print out.

Linux Commands Reference List:
------------------------------

<table>
<tbody>
<tr class="odd">
<td>ls</td>
<td>list: Lists the files and directories located in the current directory</td>
<td><ul>
<li>ls</li>
joshcarini's avatar
joshcarini committed
46
<li>`ls -a`
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<ul>
<li>shows all the files in the directory, including hidden ones</li>
</ul></li>
<li>ls -l
<ul>
<li>shows contents in a list format including information such as file size, file permissions and date the file was modified</li>
</ul></li>
<li>ls *.txt
<ul>
<li>shows all files in the current directory which end with .txt</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>cd</td>
<td>change directory: this allows users to navigate in or out of file directories</td>
<td><ul>
<li>cd &lt;folder path&gt;</li>
<li>cd folder_name
<ul>
<li>navigates into directory &quot;folder_name&quot; located in the current directory</li>
</ul></li>
<li>cd ..
<ul>
<li>navigates out of a directory and into the parent directory</li>
</ul>
cd $HOME (or $WORK)
<ul>
<li>navigates to a user's home (or work) directory</li>
</ul></li>
</ul></td>
</tr>
<tr class="odd">
<td>mv</td>
<td>move: used to move a file or directory to another location</td>
<td><ul>
<li>mv &lt;current file(s)&gt; &lt;target file(s)&gt;</li>
<li>mv * ../
<ul>
<li>moves all files from the current directory into the parent directory</li>
</ul></li>
<li>mv old_filename new_filename
<ul>
<li>renames the file &quot;old_filename&quot; to &quot;new_filename&quot;</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>cp</td>
<td>copy: used to copy a file or directory to another location</td>
<td><ul>
<li>cp &lt;current file(s)&gt; &lt;target file(s)&gt;</li>
<li>cp * ../
<ul>
<li>copies all files in the current directory and puts the copies into the parent directory</li>
</ul></li>
<li>cp -r ./orig_folder ./new_folder<br />

<ul>
<li>copies all files and directories within orig_folder into new_folder (-r indicates this is a recursive copy, so all sub-directories and files within orig_folder will be included in new_folder)</li>
</ul></li>
</ul></td>
</tr>
<tr class="odd">
<td>man</td>
<td><p>manual: displays documentation for commands</p>
<p><strong>Note:</strong> Use up and down arrows to scroll through the text. To exit the manual display, press 'q'</p></td>
<td><ul>
<li>man &lt;command name&gt;</li>
<li>man ls
<ul>
<li>displays documentation for the ls command</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>mkdir</td>
<td>make directory: creates a directory with the specified name</td>
<td><ul>
<li>mkdir &lt;new_folder&gt;
<ul>
<li>creates the directory &quot;new_folder&quot; within the current directory</li>
</ul></li>
</ul></td>
</tr>
<tr class="odd">
<td>rmdir</td>
<td><p>remove directory: deletes a directory with the specified name</p>
<p><strong>Note:</strong> rmdir only works on empty directories</p></td>
<td><ul>
<li>rmdir &lt;folder_name&gt;
<ul>
<li>removes the directory &quot;folder_name&quot; if the directory is empty</li>
</ul></li>
<li>rmdir *
<ul>
<li>removes all directories within the current directory</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>rm</td>
<td>remove: deletes file or files with the specified name(s)</td>
<td><ul>
<li>rm &lt;file_name&gt;
<ul>
<li>deletes the file &quot;file_name&quot;</li>
</ul></li>
<li>rm *
<ul>
<li>deletes all files in the current directory</li>
</ul></li>
</ul></td>
</tr>
<tr class="odd">
<td><p>nano</p></td>
<td><p>nano text editor: opens the nano text editor</p>
<p><strong>Note:</strong> To access the menu options, ^ indicates the control (CTRL) key.</p></td>
<td><ul>
<li>nano
<ul>
<li>opens the text editor in a blank file</li>
</ul></li>
<li>nano &lt;file_name&gt;
<ul>
<li>opens the text editor with &quot;file_name&quot; open. If &quot;file_name&quot; does not exist, it will be created if the file is saved</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>clear</td>
<td>clear: clears the screen of all input/output</td>
<td><ul>
<li>clear</li>
</ul></td>
</tr>
<tr class="odd">
<td>less</td>
<td><p>less: opens an extended view of a file</p>
<p><strong>Note:</strong> Use up and down arrows to scroll through the text. To exit the extended view, press 'q'</p></td>
<td><ul>
<li>less &lt;file_name&gt;
<ul>
<li>opens an extended view of the file &quot;file_name&quot;</li>
</ul></li>
</ul></td>
</tr>
<tr class="even">
<td>cat</td>
<td>concatenate: sends file contents to standard input - used frequently with pipes</td>
<td><ul>
<li>cat &lt;file_name&gt;
<ul>
<li>prints the contents of the file &quot;file_name&quot;</li>
</ul></li>
<li>cat *.txt
<ul>
<li>prints the contents of all files in the current directory that end in &quot;.txt&quot;</li>
</ul></li>
</ul></td>
</tr>
</tbody>
</table>

Adam Caprez's avatar
Adam Caprez committed
211
212
Tutorial Video
--------------
213

Adam Caprez's avatar
Adam Caprez committed
214
{{< youtube B0VdKiHNjU4 >}}