Skip to content

Commit

Permalink
move files
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Oct 22, 2023
1 parent 2ecd04e commit 4f89d79
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 83 deletions.
65 changes: 0 additions & 65 deletions docs/linux/environment-variables.md

This file was deleted.

65 changes: 65 additions & 0 deletions docs/linux/setup/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Environment variables
tags:
- windows
- linux
draft: true
---

## Linux

[Arch Wiki: environment variables](https://wiki.archlinux.org/index.php/environment_variables)

=== "System-wide"

- `/etc/profile` is sourced by all POSIX-compatible shells upon login.
- Files inside the `/etc/profile.d/` directory will also be sourced.

=== "Bash"

- `~/.profile` or `~/.bash_profile` for login bash instances.
- `~/.bashrc` for every interactive bash instance.

=== "Zsh"

- `~/.zshenv` for environment variables in all zsh instances.
- `~/.zprofile` for every login zsh instance.
- `~/.zshrc` for every interactive zsh instance.

!!! note
zsh [does not source](https://superuser.com/questions/187639/zsh-not-hitting-profile) `~/.profile` by default. You can add this line to `~/.zprofile` or `~/.zshenv` to let zsh login shells read `~/.profile`

```zsh title="~/.zshenv"
test -r ${HOME}/.profile && emulate sh -c 'source ${HOME}/.profile'
```

=== "X windows"

- `~/.xinitrc` is sourced by `startx`.
- `~/.xprofile` is sourced by display managers (e.g. GDM, SDDM)

=== "Systemd"

- `~/.config/environment.d/*.conf`: sourced by `systemd`. Also used in WayLand sessions where `xinitrc` and `xprofile` is not available.

## Windows

[Environment variables in Powershell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.3)

### Shell variables

Variables created by `set` are bound to the current session and not persistent.

```powershell
$Env:FOO = "example"
$Env:FOO
```

### Persistent variables

- GUI: Windows Settings -> Advanced system settings -> Set **Environment Variables**.
- CLI: `SetEnvironmentVariable` function.

```powershell
[Environment]::SetEnvironmentVariable('Foo', 'Bar', 'Machine')
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ tags:

How to copy files through the secure shell (SSH).

## scp command
## Using scp command

`scp` works similar to regular copy (`cp`) command.[^scp]
`scp` works similar to the regular copy (`cp`) command.[^scp]

[^scp]: https://kb.iu.edu/d/agye

```sh
scp [options] username1@source_host:directory1/filename1 username2@destination_host:directory2/filename2
```

## tar and pipe
## Using tar and pipe

```sh
tar cvf - $localdir | ssh someone@somemachine '(cd somewhere && tar xBf -)'
tar cvf - $localdir | ssh someone@somemachine '(cd destdir && tar xBf -)'
```

## Secure FTP (SFTP)
Expand All @@ -32,15 +32,15 @@ And newer versions of `scp` also use `sftp` by default.[^scpandsftp]

[^scpandsftp]: https://wiki.archlinux.org/title/SCP_and_SFTP

## Mount as a disk using sshfs
## Mount remote directory as a disk via sshfs

[sshfs](https://github.com/libfuse/sshfs) could mount remote machine's directory as a local disk.
https://github.com/libfuse/sshfs mounts a remote machine's directory as a local disk.

```sh
sshfs [user@]hostname:[directory] mountpoint
```

to unmount the directory
To unmount the directory after file operations are done:

```sh
fusermount -u mountpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Copy files selectively
title: Copy a directory tree with exclusions
draft: false
tags:
- linux
Expand All @@ -17,7 +17,7 @@ tar cf - $src | tar xvf - -C $dst

[^1]: https://docstore.mik.ua/orelly/unix3/upt/ch10_13.htm

A filter `.tarignore` excludes files/directories just like `.gitignore` does.[^2][^3]
A filter file `.tarignore` excludes stuff similar to `.gitignore`.[^2][^3]

```sh
tar -c -X .tarignore -f - srcfolder | tar xvf - -C dstfolder
Expand All @@ -39,12 +39,10 @@ The syntax is similar to `.gitignore`:
Use `--exclude` flag in `rsync` to exclude certain folder(s). [^4]

```sh

rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude anotherfoldertoexclude

```
> [! warning]

> [!warning]
> The excluded directory paths are relative to the *sourcefolder*.
[^4]: https://stackoverflow.com/questions/4585929/how-to-use-cp-command-to-exclude-a-specific-directory
[^4]: https://stackoverflow.com/questions/4585929/how-to-use-cp-command-to-exclude-a-specific-directory
8 changes: 4 additions & 4 deletions docs/linux/cpu-freq.md → docs/linux/tips/cpu-freq.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ tags:

From the [Stackoverflow post](https://askubuntu.com/questions/1415288/how-to-install-cpupower-on-ubuntu-20-04-with-kernel-5-17)

Query the CPU options
Query CPU options

```bash
grep . /sys/devices/system/cpu/cpu0/cpufreq/*
```

Change the maximum CPU frequency
Set the maximum CPU frequency

```bash
echo 4400000 | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
```

## cpufrequtils

You can install the tool `cpufrequtils`
You can also install the tool `cpufrequtils`

```bash
sudo apt install cpufrequtils
```

Set maximum CPU frequency
Set the maximum CPU frequency

```bash
sudo cpufreq-set -u 4Ghz
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4f89d79

Please sign in to comment.