Skip to content

Commit

Permalink
Merge branch 'ThirdScript-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisallenlane committed Nov 22, 2022
2 parents d7f367e + 5170ed5 commit 8dd1b2e
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cpio
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Create a specific cpio archive:
ls | cpio --create > <path/to/archive.cpio>

# Extract a specific cpio archive:
cpio --extract --make-directories < <path/to/archive.cpio>
35 changes: 34 additions & 1 deletion docker
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ docker build -t <image-tag-name> <path-of-Dockerfile>
# To start a container with an interactive shell:
docker run -ti <image-name> /bin/bash

# To run a docker container in the background:
docker run -d <image-name>

# To "shell" into a running container (docker-1.3+):
docker exec -ti <container-name> bash

Expand All @@ -28,12 +31,18 @@ docker ps
# To list all containers:
docker ps -a

# To remove all stopped containers:
docker container prune

# To remove all stopped containers:
docker rm $(docker ps -qa)

# To list all images:
docker images

# To only see all images id:
docker image ls -q

# To remove all untagged images:
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')

Expand All @@ -46,7 +55,7 @@ docker save -o <archive-name>.tar <image-name>
# To restore image from a saved tar archive:
docker load -i <archive-name>.tar

# To remove an image image:
# To remove an image:
docker image rm <image-name-or-id>

# To tag an image:
Expand All @@ -69,3 +78,27 @@ docker network connect "<network_id|name>" "<container_id|name>"

# Disconnect a specific container from network:
docker network disconnect "<network_id|name>" "<container_id|name>"

# To see the logs of a background or stopped container:
docker logs <container-id>

# To publish a port of container on localhost:
docker run -p <localhost-port>:<container-port> <image-name>

# To create a docker volume:
docker volume create <volume-name>

# To see information of a docker volume:
docker volume inspect <volume-name>

# To use a volume in the container:
docker run -v <volume-name>:<folder-path-in-container> <image>

# To link current folder between host and container for development:
docker run <image-name> -v $(pwd):<folder-path-in-container> <image>

# To copy a file from the running container to host mechine:
docker cp <container-id>:<path/to/file> <host/copy/path>

# To copy a file from host mechine to the running container:
docker cp <host/copy/path> <container-id>:<path/to/file>
3 changes: 3 additions & 0 deletions find
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ find -L /usr/ports/packages -type l
# To find and run multiple shell commands (without multiple execs):
# See: https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands
find . -type f -exec sh -c "echo '{}'; cat '{}';" \;

# To find files that are newer than a file:
find <path> -newer <target-file>
2 changes: 2 additions & 0 deletions fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# To format lines, 50 words in each line:
cat <file> | fmt -w 50
11 changes: 11 additions & 0 deletions jobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To see the background running commands:
jobs

# To see the background running commands with PID:
jobs -l

# To see the running jobs only:
jobs -r

# To see stopped jobs only:
jobs -s
5 changes: 4 additions & 1 deletion ls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ls <dir>
# To display everything in <dir>, including hidden files:
ls -a <dir>

# To display all files, along with the size (with unit suffixes) and timestamp
# To display all files, along with the size (with unit suffixes) and timestamp:
ls -lh <dir>

# To display files, sorted by size:
Expand All @@ -28,3 +28,6 @@ ls -1
# To show ACLs (MacOS):
# see also `cheat chmod` for `/bin/chmod` options for ACLs
/bin/ls -le

# To show all the subtree files (Recursive Mode):
ls -R
3 changes: 3 additions & 0 deletions man
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ man 7 ascii

# To see config:
cat /private/etc/man.conf

# To check the existence of a keyword in all of man pages:
man -k <keyword>
5 changes: 4 additions & 1 deletion tar
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ tar -cjvf /path/to/foo.tar.bz2 /path/to/foo/
# To list the content of an .tar.bz2 archive:
tar -tjvf /path/to/foo.tar.bz2

# To create a .tgz archive and exclude all jpg,gif,... from the tgz
# To create a .tgz archive and exclude all jpg,gif,... from the tgz:
tar -czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/

# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...

# To append a new file to an old tar archive:
tar -rf <archive.tar> <new-file-to-append>
9 changes: 9 additions & 0 deletions touch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# To change a file's modification time:
touch -d <time> <file>
touch -d 12am <file>
touch -d "yesterday 6am" <file>
touch -d "2 days ago 10:00" <file>
touch -d "tomorrow 04:00" <file>

# To put the timestamp of a file on another:
touch -r <refrence-file> <target-file>

0 comments on commit 8dd1b2e

Please sign in to comment.