Useful Commands: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
 
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
https://www.diskpart.com/articles/delete-hidden-partition-on-usb-drive-7201.html
= Overview =
= Overview =


{| class="wikitable"
{| class="wikitable"
! Services || Networking || OS || hardware
! style="width:200px;" | 🌐 Networking
! style="width:200px;" | 💻 OS
! style="width:200px;" | 🛠️ Hardware
|-
|-
|
| valign="top" |
|
* [[Useful Commands/Networking|Networking]]
|
* [[Useful Commands/Security|Security]]: ssh, socat
| valign="top" |
* [[Useful Commands/Service Management|Service Management]]
* [[Useful Commands/System Management|System Management]]
* [[Useful Commands/System Status|System Status]]
* [[Useful Commands/Windows only|Windows only]]
* [[Useful Commands/MacOS only|MacOS only]]
* [[Useful Commands/MacOS only|MacOS only]]
* [[Useful Commands/Windows only|Windows only]]
| valign="top" |
* [[Useful Commands/Ubuntu Desktop|Ubuntu Desktop]]
|
* [[Useful Commands/Hardware|Hardware]]
* [[Useful Commands/Hardware|Hardware]]
|-
! 📦 Packages
! 📁 File System
! 📊 Data
|-
| valign="top" |
* [[Useful Commands/Package Management|Package Management]]
* [[Useful Commands/Package Compilation|Package Compilation]]
| valign="top" |
* [[Git]]
* [[Useful Commands/File Processing|File Processing]]
* [[Useful Commands/Compression|Compression]]
* [[Useful Commands/Remote File Access|Remote File Access]]
* [[Useful Commands/Low Level IO|Low Level IO]]
| valign="top" |
* [[Useful Commands/Text Processing|Text Processing]]
* [[Useful Commands/Date & Time|Date & Time]]
* [[Useful Commands/Arithmetic|Arithmetic]]
|}
|}


Line 19: Line 40:


{| class="wikitable"
{| class="wikitable"
! Purpose || Command
! 🎯 Purpose || ⌨️ Command
|-
|-
| Verify $PATH by line. ||
| Verify $PATH by line. ||
Line 27: Line 48:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
= File System =
{| class="wikitable"
! Purpose || Command
|-
| list with color and suffix for dir and link
| <syntaxhighlight lang="bash">ls -FG</syntaxhighlight>
|-
| list add hidden files only '''single quote is necessary'''
| <syntaxhighlight lang="bash">find . -name '.*'</syntaxhighlight>
|-
| delete dist directory recursively except README.md and itself.
| <syntaxhighlight lang="bash">
find ../../assets/swagger/support ! -path *swagger/support ! -name 'README.md' -delete
</syntaxhighlight>
|-
| delete files that filename leads by - or --
| <syntaxhighlight lang="bash">rm -- -X --exclude-from</syntaxhighlight>
|-
| Set file mtime <br/>2013-09-01 00:00:00
| <syntaxhighlight lang="bash">touch -t 201309010000 FILENAME</syntaxhighlight>
|-
| create ramdisk for Linux (cannot set size)
| <syntaxhighlight lang="bash">mount -t ramfs ramfs /usr/local/ramdisk</syntaxhighlight>
|-
| create ramdisk for Linux/BSD
| <syntaxhighlight lang="bash">mount -t tmpfs -o size=128m tmpfs /usr/local/ramdisk</syntaxhighlight>
|-
| Test I/O performance of 1G write with 4K block
| <syntaxhighlight lang="bash">dd if=/dev/zero of=100k.bin bs=4k count=262144</syntaxhighlight>
|-
| Create file with 100K size
| <syntaxhighlight lang="bash">dd if=/dev/zero of=100k.bin bs=1k count=100</syntaxhighlight>
|-
| Create file with 1M size<br/>No warning on disk full
| <syntaxhighlight lang="bash">dd if=/dev/zero of=10m.bin bs=1m count=10</syntaxhighlight>
|-
| Simulate memory consumption (RAM+SWAP)
| <syntaxhighlight lang="bash">
mkdir /usr/local/ramdisk
mount -t tmpfs -o size=2G tmpfs /usr/local/ramdisk
dd if=/dev/zero of=/usr/local/ramdisk/fill.bin bs=1m count=2048
</syntaxhighlight>
|}
= Remote File System =
{| class="wikitable"
! Tool || Example
|-
| Samba (Linux) ||
<syntaxhighlight lang="bash">
sudo mount -t smbfs {remote} {local} -o \
  iocharset=utf8, \
  user={user}%{password}, \
  uid=`id -u {local user}`, \
  gid=`id -u {local group}`
</syntaxhighlight>
|-
| Samba (MacOS) ||
<syntaxhighlight lang="bash">
mount_smbfs //'{group};{user}':{password}@{remote}/{shared dir} {local dir}
smbutil view //Guest@192.168.91.65
smbutil view //'WORKGROUP;Administrator':12345@192.168.1.2 # for Windows 2K3
</syntaxhighlight>
|-
| Samba (FreeBSD) ||
<syntaxhighlight lang="bash">
mount -t smbfs -o '-N' //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples # Using ~/.nsmbrc
mount_smbfs -I 192.168.91.65 //raymondwu@RaymondWu-PC/TikaSamples /var/tika/samples
smbutil view -I 192.168.91.65 //raymondwu@RaymondWu-PC
</syntaxhighlight>
|}
= Compression =
{| class="wikitable"
! Tool || Example
|-
| zip ||
<syntaxhighlight lang="bash">
zip -r front-end.zip index.html static/
unzip -l front-end.zip
unzip -p front-end.zip index.html
</syntaxhighlight>
|-
| tar ||
<syntaxhighlight lang="bash">
tar --exclude=".*" -zcvf ~/solr-4.3.0.tgz solr-4.3.0
tar -C /usr/local --exclude '.*' -zcvf tika-1.4-pxx.tgz tika
</syntaxhighlight>
|-
| gzip ||
<syntaxhighlight lang="bash">
gzip -k taiwan-taco.map
gzip -l taiwan-taco.map.gz
  compressed uncompressed  ratio uncompressed_name
    25400590    38204880  33.5% taiwan-taco.map
</syntaxhighlight>
|-
| xz ||
<syntaxhighlight lang="bash">
xz -zk hd-20190227.csv
xz -vt hd-20190227.csv.xz
hd-20190227.csv.xz (1/1)
  100 %    344.1 KiB / 1,458.1 KiB = 0.236
</syntaxhighlight>
|-
| dd ||
<syntaxhighlight lang="bash">
# Make an ISO image.
df -h
umount /dev/disk2
dd if=/dev/disk2 of=Win7.iso bs=2048 count=1000
file Win7.iso
Win7.iso: ISO 9660 CD-ROM filesystem data 'GRMCULFRER_TW_DVD              ' (bootable)
kill -USR1 {pid of dd}
</syntaxhighlight>
|}
= Other Topics =
* [[Useful Commands/File Processing|File Processing]]
* [[Useful Commands/Text Processing|Text Processing]]
* [[Useful Commands/Networking|Networking]]
* [[Useful Commands/Date & Time|Date & Time]]
* [[Useful Commands/Service Management|Service Management]]
* [[Useful Commands/Package Management|Package Management]]
* [[Useful Commands/Package Compilation|Package Compilation]]
* [[Useful Commands/System Management|System Management]]
* [[Useful Commands/System Status|System Status]]
* [[Useful Commands/Arithmetic|Arithemetic]]
* [[Useful Commands/Security|Security]]: ssh, socat
* [[Git]]

Latest revision as of 01:53, 17 September 2026

Overview

🌐 Networking 💻 OS 🛠️ Hardware
📦 Packages 📁 File System 📊 Data

Trouble shooting

🎯 Purpose ⌨️ Command
Verify $PATH by line.
echo $PATH | tr ':' '\n'
echo $PATH | tr ':' '\n' | grep 'snap'