You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shells are command-line interpreters that accept commands that are then sent to the OS kernel for processing. See list of popular shells I saved as an img on my iPad. You can use any shell installed on the computer by typing its name on the CLI.
@@ -241,7 +240,6 @@ Searches for executables and man page files
241
240
242
241
whereis cd
243
242
244
-
[Back to table of contents](#toc)
245
243
246
244
## <spanid="cli-help"></span>Getting CLI help
247
245
@@ -288,4 +286,356 @@ Searches for executables and man page files
288
286
|`.htm`, `.html`| any web browser, often less |
289
287
|`.odt`| LibreOffice, OpenOffice.org, any word processor |
290
288
|`.pdf`|`.xpdf`, Adobe Reader |
291
-
| `.tif`, `.png`., `.jpg` | Gimp
289
+
| `.tif`, `.png`., `.jpg` | Gimp
290
+
291
+
## <spanid="linux-file-system"></span>The Linux file system
292
+
The Linux file system and the file system hierarchy standard (FHS)
293
+
294
+
- The Linux file system uses a hierarchy structure to organize data.
295
+
- Linux systems have a standard set of subdirectories at the root.
296
+
297
+
| directory | description |
298
+
| :--- | :--- |
299
+
| bin | executables necessary to run the OS |
300
+
| boot | bootloader files to boot Linux |
301
+
| dev | devices that send/receive data sequentially (printers/mice); devices that are block-oriented (HDs, flash drives) |
302
+
| etc | text-based config files used by the system |
303
+
| home | home folders for users |
304
+
| lib -> usr/lib | code libraries for programs in the bin or sbin directories |
305
+
| lib64 | 64-bit libraries |
306
+
| media | used by some distros to mount external devices |
307
+
| mnt | used by some distros to mount other external devices |
308
+
| opt | contains files for programs you can install manually |
309
+
| proc | pseudo file system for processes |
310
+
| root | root user's home directory |
311
+
| sbin | mgmt and config files |
312
+
| srv | where services save their files (e.g., httpd) |
313
+
| sys | hardware within system |
314
+
| tmp | temporary files created by file system |
315
+
| usr | application files |
316
+
| var | Linux variable data and log files |
317
+
318
+
### <spanid="file-system"></span>Disk file systems
319
+
-__ext2:__ second extended file system. Data is stored in hiearchical fashion (dirs/files). 2 TB is max file size.
320
+
-__ext3:__ updated version of ext2. Adds journaling, which records transactions. If the system restarts uncleanly, the entire file system doesn't need to be checked entirely as with ext2.
321
+
-__Reiser:__ similar to ext3 in that journaling makes recovery much quicker.
322
+
-__ext4:__ updated version of ext3.
323
+
324
+
325
+
## <spanid="files"></span>Files and directories
326
+
-`touch -d "February 1 2017" file.txt`: Allows you to specify the modification timestamp.
327
+
-`mkdir -p newdir/newsubdir/newsubdir2`: Create a directory and its parents if they don't exist.
328
+
-`rmdir $dir`: Can only delete empty directories
329
+
-`cp -puR srcfile dstfile`:
330
+
+__`p`__ = preserve original ownership
331
+
+__`u`__ = update (only if src is newer or dst doesn't exist)
332
+
+__`R`__ = recursive
333
+
-`mv srcfile directory/`: Move/rename file to indicate directory
334
+
335
+
336
+
## <spanid="archives-compression"></span>Archives and compression
337
+
338
+
### <spanid="archives"></span>Archives
339
+
-__tar:__ Stands for “tape archive.” Combines files but doesn’t compress them. You can pass flags to both archive and compress, since Gzip and Bzip2 are for compressing only. **Note that the order of the flags matters for `tar` command.**
340
+
+`-c` = create archive
341
+
+`-f` = read the archive from or write the archive to the specified file
342
+
+`-t` = list archive's content w/o extracting it
343
+
+`-x` = extract tarball
344
+
+`-v` = verbose output (lists files extracted)
345
+
+`-z` = compress using gzip
346
+
+`-j` = compress using bzip2 (like gzip but more resources intensive)
347
+
348
+
__Archive (no compression)__
349
+
350
+
| Command | Notes |
351
+
| :--- | :--- |
352
+
|`tar -cf tarball.tar dir-to-tar`| creates the tarball from dir-to-tar directory |
353
+
|`tar -cf tarball.tar file1 file2`| creates the tarball from files indicated |
354
+
355
+
__Unarchive (no compression)__
356
+
357
+
| Command | Notes |
358
+
| :--- | :--- |
359
+
|`tar -tf tarball.tar`| show contents of tarball w/o unarchiving |
-__zip:__ Like in Windows. It's the only command that both compresses and archives. It's also the simplest b/c it has few options.
382
+
+ Examples: Compress with `zip` and extract with `unzip`
383
+
* `zip file.zip file1 [file2]` = create a zipped archive of the specified files
384
+
* `zip -r file.zip dir-to-zip`
385
+
- `-r` is required to go into directories and zip their contents, or else you'll zip an empty directory
386
+
* `unzip file.zip`
387
+
-__gzip:__ Compressed file format. Not for archiving, but for compressing.
388
+
+ Compress with `gzip` and extract with `gunzip`.
389
+
+ File extension is __.gz__.
390
+
+__Note:__ Gzip deletes the original unless you pass the `-c` flag, or the `-k` flag for "keep."
391
+
+ Examples:
392
+
*`gzip file.tar` = will replace original file
393
+
*`gzip -c file.tar > file.tar.gz` = will keep original file and create file.tar.gz
394
+
*`gzip -k file.tar` = same as above
395
+
*`gunzip file.tar.gz` = uncompress file
396
+
-__bzip2:__ Better than Gzip, especially for bigger files. Not for archiving, but for compressing.
397
+
+ Compress with `bzip2` and extract with `bunzip`. File extension is __.bz2__
398
+
+ Examples:
399
+
*`bzip2 file.tar`
400
+
*`bunzip2 file.tar.bz2`
401
+
402
+
403
+
## <spanid="searching"></span>Searching for and extracting data from files
404
+
405
+
### <spanid="viewing-text"></span>Viewing text
406
+
407
+
| Command | Purpose |
408
+
| :--- | :--- |
409
+
|`cat`| display contents of a file |
410
+
|`less -M`| reads file with pagination. <br><br>use `/` to search fwd and `?` to search backwards<br><br> `-M` shows lines you're reading and total, plus percentage <br><br>`-N` shows line numbers on the left <br><br> `G` goes to beginning and `shift` + `G` goes to end |
411
+
|`head`| read first 10 lines of a file. `-n $num_lines`|
412
+
|`tail`| read last 10 lines of a file; `-f` = follow |
0 commit comments