Linux and windows cofigurations snippets
- Connect the drive
- run the command
lvm
- Inside the
lvm
terminal pvscan
<- (note the PV name)lvscan
<- (note the LV names)lvchange -ay /dev/{pv-name-here}
eglvchange -ay /dev/fedora_a/home
- Inside the
- Now mount the dive with that name:
sudo mount /dev/fedora_a/home /tmp/fed24/
- Here the drive is ready for use in
/tmp/fed24
To remove the disk:
- umount /mnt
- lvm
- lvchange -an /dev/{pv-name-here}
The linux kernel defines the number of partitios per MMC block device to be CONFIG_MMC_BLOCK_MINORS
.
This defines the number of minors per block device. One is needed for every partition on the disk,
plus one for the whole disk. Number of total MMC minors is 256, so your number of supported block devices
will be limited by 256 divided by CONFIG_MMC_BLOCK_MINORS
. Default is 8 to be backwards compatible with
previous hardwired device numbering.
pvs
:
pvs — report information about physical volumes
lvdisplay
:
lvdisplay — display attributes of a logical volume
To mount use the regular procedure:
- Create a directory
mkdir HD_Laptopo
- Mount as a regular partion
mount mount /dev/vg_<host>/lv_home ./HD_Laptopo
eog <path to image>
xdpyinfo
Get the display size:
xdpyinfo | grep dim
`xdg-open
prompt $$
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
net share <share_name>=<full path> /GRANT:<user>,[READ | CHANGE | FULL]
net share
ping 192.168.1.255
arp -n
sudo usermod -a -G sudo <user>
Use adduser
, its a front end for the more low-level useradd
.
adduser
creates the $HOME
for the in-creation user, while useradd
does not.
https://www.veracrypt.fr/en/Home.html
findstr /spin /c:"find in text" [files]
s
: recursivep
: skip non-printable charsi
: case insensitiven
: Print line numbers/c:
: String to look up[files]
: a regex for the file name e.g.:c_*.h
grep -Riln 'Text to find' /<path>
Instead of chainig grep calls with pipes, use the next option.
grep -v -e <regexa> -e <regexb> -e <regexc> -e <regexd>...
Other option is to enable the flag -E
.
grep -Ev '(regexa|regexb|regexc|...)'
Or use a file which contains all the patters, one per line.
grep -v -f patterns.txt
grep -rnw '/path/to/somewhere/' -e 'pattern'
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
Along with these, --exclude, --include, --exclude-dir flags could be used for efficient searching:
This will only search through those files which have .c or .h extensions:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
This will exclude searching all the files ending with .o extension:
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
For directories it's possible to exclude a particular directory(ies) through --exclude-dir parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
find -name "*.swp" - exec rm {} ';' # The command must be terminated with ';' or '\;'
$ cat > filename.txt
write stuff
other stuff
and so on
^D
Done
setuid
and setgid
are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group respectively and to change behaviour in directories.
The /etc/skel
is a directory used by the command useradd
to create
the default settings in a new user's home directory.
roor@pc/etc/skel#ls -a
. .. .bashrc .profile
The settings for the command useradd
can be changed by editing
/etc/default/useradd
To get files available via http:
cmd > ps
:: in power shell is an alias for Invoke-WebRequest
wget https://www.example.com -OutFile out.html
:: for older PS versions
Invoke-WebRequest http://www.google.com/ -OutFile c:\google.html
As an alternative use curl, it needs to add more paramenters to control the output which does not goes to the a file with the same name as wget:
curl <url> -o <filename>
To act the same as wget, add {}
to the URL to create the filename or the
folder structure. e.g.:
curl http://example.com/{dir}/{file}.pdf -o '#1/#2.pdf'
This will create the file dir/file.pdf
with the same name.
To know which tty device is currently in use, use the command tty
which returns the device being used.
As a side note is important for logging programs to check and adapt for the case in which the print output is a tty and when a file, this to take into account the buffering or pipe size. In the case of redirection with pipe the default size for a pipe named or not is 4k. If the buffer is not flushed some logs get lost in the pipe if not handled correctly.
Install with non-sudo permisions in a /
folder:
sudo install -d -o $(whoami) -g $(whoami) <folder_name>
There are at least 2 possiblities:
This command creates a virtual drive with the given path:
subst z: b:\user\betty\forms :: creates the z: virtual drive pointing to c:\user\betty\forms
subst z: \d :: delete the virtual drive
2. The \\?\
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
sysfs
was designed to add structure to sysproc
and provide a uniform way
to expose system information and control points to user-space from the kernel.
Now, the driver framework in the kernel automatically creates directories under
/sys
when drivers are registered, based on the type and the values in their
data structures.
procfs
allowa arbitraryfile_operations
,sysfs
is more restricted.- `procfs receives a file_operations struct, which contains function pointers that determine what happens to every file-based system call (open, read, mmap)
- While
sysfs
there is ony two methodsshow
andstore
which linux uses to implement the open, close, read, write and lseek .