How Do I: A Linux Q&A

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 17:00, 16 February 2024 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

HOW DO I?

Answers to common Linux configuration and end user modification

note: This started over 20 years ago as a simple text file on a BBS. Please forgive some formatting...

index: how do i...

Contents

[LOGIN SWITCHING]


Switch between boot to graphical xwindows login or standard text login

Edit the /etc/inittab file and look for "Default runlevel". Runlevel values differ from one distribution to another.

Set to TEXT Multiuser Boot Login (for Redhat):

id:3:initdefault:

Set to GRAPHIC X11 Boot Login (for Redhat):

id:5:initdefault:


[RESTRICT ROOT LOGIN LOCATIONS]


(see RootAccess.html for more information)

An empty /etc/securetty file prevents root login on any devices attached to the computer.

Edit the /etc/ssh/sshd_config file and set the PermitRootLogin parameter to no.


[PREVENT CONSOLE MONITOR BLANK]


This is like sleep mode, the monitor screen goes blank after a period of inactivity until a key press.

Modify the .bash_profile in your home directory.

echo "setterm -blank 0" >> .bash_profile


[MODIFY DEFAULT COMMAND KEYWORDS AND VALUES]


For example, you can stop nslookup from complaining about deprecation by using the -sil switch. To make it automatically assume the -sil switch simply modify your .bashrc file for your shell.

vi /home/username/.bashrc

add the following:

alias nslookup='nslookup -sil'


[MORE BASH COMMAND ALIASING]


Open the .bashrc file

vi .bashrc

Add the following (these are example aliases):

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias last='last -a'
alias nslookup='nslookup -sil'
alias ftp='ftp -i'


[CHANGE BASH CUSTOM PROMPT]


he appearance of the prompt is governed by the shell variable PS1. The default prompt is customized on many linux distributions. It is sometimes customized differently for root and regular users.

Redhat Linux default prompt:  PS1='[\u@\h \W]\$ '
Trustix Linux default prompt:  PS1='\u@\h \w\$ '

To see how the current prompt is set

echo $PS1

Set prompt style on login, edit .bash_profile (or equivalent) example:

PS1='root@\h \w\$ '
export PS1
 
  • PS1 - The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string. The default value is \s-\v\$ .
  • PS2 - The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is >
  • PS3 - The value of this parameter is used as the prompt for the select command
  • PS4 - The value of this parameter is expanded as with PS1 and the value is printed before each command bash displays during an execution trace. The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection. The default is +
   * \a : an ASCII bell character (07)
   * \d : the date in “Weekday Month Date” format (e.g., “Tue May 26″)
   * \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
   * \e : an ASCII escape character (033)
   * \h : the hostname up to the first ‘.’
   * \H : the hostname
   * \j : the number of jobs currently managed by the shell
   * \l : the basename of the shell’s terminal device name
   * \n : newline
   * \r : carriage return
   * \s : the name of the shell, the basename of $0 (the portion following the final slash)
   * \t : the current time in 24-hour HH:MM:SS format
   * \T : the current time in 12-hour HH:MM:SS format
   * \@ : the current time in 12-hour am/pm format
   * \A : the current time in 24-hour HH:MM format
   * \u : the username of the current user
   * \v : the version of bash (e.g., 2.00)
   * \V : the release of bash, version + patch level (e.g., 2.00.0)
   * \w : the current working directory, with $HOME abbreviated with a tilde
   * \W : the basename of the current working directory, with $HOME abbreviated with a tilde
   * \! : the history number of this command
   * \# : the command number of this command
   * \$ : if the effective UID is 0, a #, otherwise a $
   * \nnn : the character corresponding to the octal number nnn
   * \\ : a backslash
   * \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
   * \] : end a sequence of non-printing characters


[CONFIGURE SYSLOG TO LOG TO A REMOTE HOST]


1.) Setting up a remote log server is not covered. To make syslog spool the logs to a remote host edit /etc/syslog.conf and add the following line at the bottom after everything else:

*.*				@10.10.1.1

Where 10.10.1.1 is the IP address of the remote log server.

2.) Setting up syslog on the remote log server. With the log server, (the machine accepting all of the remote logs), all you have to do is launch syslogd with the -r switch, specifying remote logging capabilities. Make sure that you remember to ADD: syslog 514/udp to the /etc/services file as well, on the server, or it will not listen to the specified port.

Now we have to configure our server to accept those connections on port 514, so we do that by editing /etc/rc2.d/S10syslogd and we change the SYSLOGD="" line to the following:

SYSLOGD="-rm 0"

In the above line, the r tell syslogd there will be clients connecting to it, and that it should accept them, the m 0 signifies we don't want to see - MARK - entries in the logs that our server records.


[GET DNS WORKING USING resolv.conf, hosts, and hosts.conf FILES]


Often your computer's hostname and/or host and domain name do not really exist on the Internet. Your linux workstation has to be able to determine its own host and domain name, real or not, for applications and services to run correctly.

To use both a local hosts file and an external name server, /etc/host.conf should read

order hosts, bind
multi on

That will cause the system to look in /etc/hosts first, and if it can't resolve the IP, then it checks /etc/resolv.conf for a nameserver address.

In resolv.conf, you only need the the following:

domain yourdomain.com
nameserver 192.168.1.1

Replace the IP with a valid DNS server IP address. An example hosts file needs only have the following:

127.0.0.1	myboxen		localhost.localdomain   localhost
24.208.79.172			myboxen.foo.com		myboxen

[TURN ON AND OFF PC SPEAKER BEEP IN CONSOLE AND X]


In Xfree you can turn the PC-speaker bell on and off with the xset commands option b, type:

xset b off

To turn off the pc speaker on console mode use setterm with the argument blength, type:

setterm -blength 0


[SUPRESS diskcheck WARNING MESSAGES FOR SPECIFIC PARTITIONS ONLY]


diskcheck is a cron script in /etc/cron.daily on Redhat. Although it is merely a shell script, it has a configuration file /etc/diskcheck.conf Modify the 'exclude' line to prevent diskcheck from looking at specific mounted file system partitions. (redhat lists the following parameters):

  • defaultCutoff - disk drives reach this percent capacity, it

will be reported. For example, if defaultCutoff = 90, an email will be sent when the monitored disk drives reach 90% capacity.

  • cutoff[/dev/partition] - Override the defaultCutoff for the

partition. For example, if cutoff['/dev/hda3'] = 50 is specified, diskcheck will alert the system administrator when the partition /dev/hda3 reaches 50% capacity.

  • cutoff[/mountpoint] - Override the defaultCutoff for the mount

point. For example, if cutoff['/home'] = 50 is specified, diskcheck will alert the system administrator when the mount point /home reaches 50% capacity.

  • exclude - Specify one or more partitions for diskcheck to ignore.

For example, if exclude = "/dev/sda2 /dev/sda4" is specified, diskcheck will not alert the system administrator if /dev/sda2 or /dev/sda4 reaches the specified cutoff percentage.

  • ignore - Specify one or more file system types to ignore in the

format -x filesystem-type. For example, if ignore = "-x nfs -x iso9660" is specified, the system administrator will not be alerted about nfs or iso9660 file systems reaching capacity.

  • mailTo - Email address of the system administrator to alert when

partitions and mount points reach the specified capacity. For example, if mailTo = "webmaster@example.com" is specified, webmaster@example.com will be emailed alerts.

  • mailFrom - Specify the identity of the email sender. This is useful

if the system administrator wants to filter the mail from diskcheck. For example, if mailFrom = "Disk Usage Monitor" is specified, email will be sent to the system administrator with the sender Disk Usage Monitor.

  • mailProg - Specify the mail program to use to send email alerts. For

example, if mailProg = "/usr/sbin/sendmail" is specified, Sendmail will be used as the mail program.


[DISABLE ANNOYING KDE Autorun WHEN CDROM IS IN DRIVE WHEN KDE STARTS]


Auto-run support is controlled in KDE by the Autorun.desktop module, which is automatically started when you start KDE by virtue of its being in the ~/.kde/Autostart folder.

If you want to disable autorun (but not automount; there's a difference), then just remove this item from the folder (you can copy it to another folder, like your Desktop or something in case you ever want to re-enable it). Just keep in mind that this will most likely disable autorun of data CDs as well.

If you want to CHANGE the default cd player, then right-click on the item, and pick Properies. Select the Execute tab, and look for the "--cdplayer=/usr/bin/kscd" part.

It is also possible to edit the line:

Exec=/usr/bin/autorun -l --interval=1000 --cdplayer=/usr/bin/kscd


[DISPLAY VOLUME LABEL ON MOUNTED CDROM DISC]


There is a small utility called volname included with recent versions of the eject program. Alternatively you can run this shell command:

dd if=/dev/cdrom bs=1 skip=32808 count=32 

assuming /dev/cdrom is the device file name for your drive.


[FORCE EJECT DVD / CDROM DISC]


Determine where it is mounted using the 'df' command then, not against the dev but the mountpoint issue the following:

sudo fuser -km /media/label

[FORMAT FLOPPY]


Insert the floppy and do not mount it. If mounted, type

umount /dev/fd0

-> Format Floppy (Redhat):

bash$ fdformat /dev/fd0

-> Format Floppy (other):

floppy --format /dev/fd0

[PARTITION AND FORMAT LINUX HARD DISK]


Format a hard drive / hard disk / harddrive harddisk from the linux command line. You cannot edit the partition table if mounted.

Using fdisk and knowing the disk device ID (for example we will partition a second harddrive that is /dev/sdb

sudo fdisk /dev/sdb

You're in the fdisk interface, select:

  • press 'p' to show the partition table, do this and make sure that you are using the correct partition (remember sdb is just our example)
  • press 'n' to create a partition, follow prompts. The first partition or if there is only one should be made primary. If you press ENTER though the defaults you will create one large partition using most of the drive.
  • press 'w' to write the changes to disk. You've not created the partition until you write.

Now to format the new partition. For this example we will format as the most common linux type as of this writing (updated for ext4)

sudo mkfs.ext4 /dev/sdb1

Or if you wish to make a swap partition

sudo mkswap /dev/sdb2

[FORMAT PARTITION TO FAT32]


Format the first partition of drive c to be FAT 32, example:

mkfs.vfat -F 32 /dev/hdc1


[DOWNLOAD TO CONSOLE WITHOUT A BROWSER]


  • all the major distributions include the wget downloading tool.
 bash$ wget http://place.your.url/here
  • recursively mirror entire web-site directory trees
 bash$ wget -m http://target.web.site/subdirectory
  • follow only relative links and skip GIF images
 bash$ wget -m -L --reject=gif http://target.web.site/subdirectory
  • resume interrupted downloads if supported by the server.
 bash$ wget -c http://the.url.of/incomplete/file
  • retry the URL several times
 bash$ wget -t 5 http://place.your.url/here
  • schedule a download to take place later in the day using 'at'
   at 2300
   warning: commands will be executed using /bin/sh
   at> wget http://place.your.url/here
   at> press Ctrl-D 


[ENABLE IP FORWARDING]


To enable IP (IPv4) Forwarding in RedHat linux you need to activate it in the kernel. You can configure this to happen automatically or you can activate it on the fly.

To enable IP forwarding instantly:

 echo 1 > /proc/sys/net/ipv4/ip_forward

Placing that in the rc.local file will cause it to be executed during boot. Or you can set this up in the sysconfig network script. Edit /etc/sysconfig/network and change or add the following line:

 FORWARD_IPV4 = YES


[RESIZE WINXP NTFS PARTITION TO MAKE ROOM FOR LINUX]


  1. Download the SystemRescueCD ISO image (100 MB very useful softwares).
  2. Burn the ISO image to a CD.
  3. Boot from the CD.
  4. Enter run_qtparted when you get a command prompt.
  5. Select your disk on the graphical screen.
  6. Select your NTFS partition to be resized.
  7. Right click with the mouse and choose Resize.
  8. Set the new partition size.
  9. Commit your changes in the File -> Commit menu.

If your keyboard and mouse stop responding during resizing then please just be patient.

Reference: http://mlf.linux.rulez.org/mlf/ezaz/ntfsresize.html for more details.


[RESIZE LINUX PARTITION]


QTPARTED is a utility like Partition Magic. QPARTED is supposed to resize existing ext3 partitions. It wouldn't when I tried. Partition Magic versions seven and above or QPARTED may have problems with ext3. The solution, convert the partition file system type to ext2, resize it, then convert it back. for your ext3 journalling file system: You can use 'tune2fs' on linux to turn journaling off and make it basically ext2.

technical comments: Using a Linux bootable disk or cd the utilities are be sure to boot from a rescuse disk. Do not do it to a mounted drive (unless it is mounted read-only but that is still crazy)

WARNING! PARTED and QTPARTED are limited. Testing had determined that attempting to resize an ext2 or ext3 logical drive within an extended partition, or the extended partition itself cannot be accomplished with Partition Magic 7, or parted/qtparted (always or most of the time).

In theory if the partition is a primary in ext2, either parted or partition magic should be able to perform the resize operation.

  • ..convert to ext2:
 tune2fs -O ^has_journal /dev/hdaX
  • ..check the drive:
 fsck -f /dev/hdaX
  • ..resize the partition(s)
 run_qtparted (or reboot to your Partition Magic 7 or 8 disc)
  • ..convert back to ext3:
 tune2fs -j /dev/hdaX

troubleshooting: qtparted gives an error and refuses to resize the ext2 partition. (developing workaround) resize2fs doesn't resize a partition, just file system sitting on top. Fdisk can be used in a hazardous workaround along with resize2fs.

note: sources say qtparted doesn't support ext3, however, the qtparted supplied with "SystemRescueCD" (a great emergency boot disc) claims to support ext3.

Unfortunately, this documentation is sketchy on performing all types of partition resizing because it is not always possible to resize a partition, and as better tools are developed what is not possible today could be possible tomorrow. What is covered here experience provides.


[DETACH PROCESS FROM SHELL AND LEAVE RUNNNING AFTER SHELL CLOSED]


To keep a program running while not logged on, you need to use the prefix your command with the word nohup. You will need to run this command in the background.

for example:

 nohup grep 'director' emp.lst & | nohup sort &

 


[RESUME A STOPPED JOB IN LINUX]


If you see [1]+ Stopped at the console you've stopped a process and placed it in the background. You may have accidentally pressed Ctrl+Z or you intentionally stopped the process job and now you wish to resume it.

type:

fg

You can add the job number behind the fg command, if there is only one job it will be job 1 and default to that job. Learn more about Job Management in Linux.

 

[RUN LEGACY VERSIONS OF IRCII IN BACKGROUND WHEN NOHUP FAILS]


For some reason certain programs don't like to be ran nohup, like ircii-4.4Z, which will stop immediately. A work around is to use screen. For example:

 screen irc -b -c \#channelname NickName

It will load in a forground window, however, you can disconnect from the shell and it will remain running. There's probably a better way. Note that the background switch doesn't work in ircii-4.4Z .

 

[EMERGENCY BOOT RECOVER ROOT PASSWORD OR FIX MOUNTING ISSUE]


In an emergency you may have to recover from problems such as a lost root password, messed up fstab configuration, harddrive corruption, device driver or kernel error; all of which may prevent normal booting.

If you lost your root password, you may gain access to the system by booting into 'single user mode' from the system console (not remote).

For Lilo: at boot screen press 'tab' and type: 'linux single'. This will pass the parameter to the kernel booting linux into single user mode.

For Grub:

Your system might be messed up to the point it will not boot into single user mode. You may need to repair your fstab file, remove a kernel module, or some other boot parameter or perhaps you need to repair file system damage. To do this you may boot linux into emergency mode.

For Lilo:

For Grub:

Another way to boot lilo into an emergency mode

For Lilo: at boot screen press 'tab' and type: 'linux init=/bin/sh'

Now that you are booted into emergency mode you will note that your file system is mounted read-only. To get into a file such as /etc/fstab you will need write access. Remount the file system read-write.

Bash: type 'mount -n -oremount,rw /'

Notice root is / and the option is 'remount' or

mount -n -oremount,rw /

Now you have full read-write access to the filesystem. You may need to mount other partitions into /mnt or perform copy or restore operations. You can also chroot.

If your bootloader is messed up, you should boot from a boot floppy or cdrom. Suggested here is SystemRescueCd, a utility made with Gentoo, any Tiny Linux on floppy, or a Knoppix CD. Determine your root partition so you can rebuild your boot loader. Use 'fdisk -l'. You can make a /mnt/rootpart then to mount your root partition too and 'chroot /mnt/rootpart'

[SET DATE TIME COMMAND LINE CONSOLE]

The format date --set="STRING"

Set date from the command line

date +%Y%m%d -s "20120418"

Set time from the command line

date +%T -s "11:14:00"

[LIST CONTENTS OF COMPRESSED TAR ARCHIVE]


List contents of filename.tar to the screen

tar -tvf filename.tar

List the contents of a gnuzip (gzip) compressed tar archive.

tar -ztf name-of-file.tgz

Verbosely

tar -ztvf name-of-file.tgz

Search the archive

tar -ztf name-of-file.tgz | grep -i "search string"

Verbosely

tar -ztvf name-of-file.tgz | grep -i "search string"

Online Resources

[HOWTO EXTRACT xz / tgz FILE IN LINUX]

The xz format is a single-file compression format that is based on the LZMA2 algorithm. Requires xz toos. Mint/Ubuntu install

sudo apt install xz-utils

extract/unzip xz tar file

tar -xvf userfiles.tar.xz

Archive types tar.gz and tar.xz are both compressed tar-files, however, using variations on the compression method. For the user there is no difference when extracting either type of file, with the exception of extraction speed. The compression method for xz produces a more densely compact file resulting in a higher level of compression at the expense of speed. It may take longer, or even significantly longer to extract files from a xz archive.

[HOWTO COMPRESS with tar zip tar.gz tgz]

Back up a directory of files and preserve the path.

tar -zcvf sourcefiles archive.tar.gz
  • -z compress using zip
  • -c create
  • -v verbose
  • -f archive file to create

You can add -p to preserve absolute names, so that the path will begin with the root / and all the way to the directory location. This is really only useful for doing backups/

[SET PATH VARIABLE SHOW PATH VARIABLE]

The current path environmental variable can be viewed

echo $PATH

capital letters on PATH. Want to know if a command is in $PATH?

which command

Need to add a directory path to the shell path statement for your own scripts?

  • Per user shell
vi ~/.profile

Look for the line with a comment about "set PATH so it includes user's private bin directories" and add your custom path in there like this: ( added /myscripts to the path )

PATH="$HOME/bin:$HOME/.local/bin:/myscripts:$PATH"

note: In the past we used ~/.bash_profile and had to include "export PATH"

Look at /etc/profile which is used for each new user directory created. It has a script still looking for .bash_profile so it appears that if a .bash_profile is created, the script will identify its existence and use it.

Note: Recommend you use the .bashrc method mentioned below this note! It seems to work very well on most systems.

IF THAT DOESN'T WORK - THIS WILL ...

vi ~/.bashrc
PATH="/myscripts:$PATH"

Note: the .bashrc is executed every time a bash shell is opened and .bash_profile only if it's a login shell.

If you "sudo bash" then your custom path directories have vanished! /etc/sudoers is configured to replace your PATH with a default one. You have a couple options, either remove Defaults secure_path= from /etc/sudoers or add your custom directory to the secure_path in /etc/sudoers. For some stupid reason when you visudo the /etc/sudoers file opens in nano! stupid!

sudo update-alternatives --config editor

Will allow you to fix the stupid editor default (idiots at Ubuntu and Mint don't you think nano is for dosy people?)

sudo visudo

Adding to the PATH for ALL USERS can be done like this:

  • edit /etc/profile, put the modified PATH in there.
PATH=$PATH:/your/path; export PATH

Add that line to the bottom of /etc/profile


keywords: bash path bashrc bash_profile bash_history command set

[PWD WORKING DIRECTORY COMMAND DOESN'T SHOW ESCAPE SPACES IN PATH]

The space character can cause problems when copy and paste a path from the command line. We use the backslash to escape them. The pwd command doesn't do this, so here is an alternative:

printf "%q\n" "$(pwd)"

Does the same as pwd with the spaces escaped.

[HOWTO EXTRACT xz FILE IN LINUX]

The xz format is a single-file compression format that is based on the LZMA2 algorithm. Requires xz toos. Mint/Ubuntu install

sudo apt install xz-utils

extract/unzip xz tar file

tar -xvf userfiles.tar.xz

[DISK USAGE, FINDING LARGE DIRECTORIES]

The du command "Disk Usage" is helpful. See examples:

  • show directories 1GB or over
du -h --threshold=1G
  • and sort them by size
du -h --threshold=1G | sort -h
  • and limit depth of search
du -h --threshold=1G --max-depth=1 | sort -h

Using --max-depth= controls how many subdirectory levels du will display in the listing. Each level still includes an estimation including all depth of subdirectory however the total is combined without the need for showing greater depth into the directory tree than what is specified by this parameter. In our example du will list only the first directory layer and the sizes including contents. The total space consumption for the current directory tree will also be reported.

du -BM --max-depth=1 | sort -nr

sorted largest first

[DETERMINE LINUX VERSION KERNEL VERSION OR DISTRIBUTION VERSION]

See: Determining Your Linux Version

[COMPARE FILES IN LINUX]

There are a number of tools to accomplish this. Tools for binary files and for text files, and a combination of the two exist. Common examples:

  • cmp - compare two files byte by byte
  • diff - compare files line by line

cmp' reports the differences between two files character by character, instead of line by line. As a result, it is more useful than 'diff' for comparing binary files. For text files, 'cmp' is useful mainly when you want to know only whether two files are identical.

  • comm - compare two sorted files line by line

Other commands: dircmp, uniq, ...

In an example, lets compare two files without regards to binary or text, just to determine if identical.

cmp file1 file2

Compares file1 to file2, reading each file byte-by-byte and comparing them until one of the byte pairs is not equal. When a difference is found, it will output the location in the file where the difference was found, and exit. By default, `cmp' outputs nothing if the two files have the same contents. If one file is a prefix of the other, `cmp' prints to standard error a message.

[LIST FILES IN FOLDER BASED ON DATE RANGE OR NEWER / OLDER THAN]

Some related searches: linux list files modified after date and linux list files for a specific date range. This is not a task best suited for the 'ls' command. Instead, we defer to the 'find' command.

You can use the find command to find all files that have been modified after a certain number of days. For example, to find all files in the current directory that have been modified since yesterday (24 hours ago) use:

find . -maxdepth 1 -mtime -1

Note that to find files modified before 24 hours ago, you have to use -mtime +1 instead of -mtime -1.

find . -type f -newermt '1/30/2017 0:00:00'

This will find all files modified after a specific date. A range:

m   The modification time of the file reference
t   reference is interpreted directly as a time

try

find . -type f -newermt 20111222 \! -newermt 20111225

note that you can directly specify your dates:

find -type f -newermt "2011-12-22" \! -newermt "2011-12-24"

or

find -type f -newermt "2011-12-22 00:00:00" \! -newermt "2011-12-24 13:23:00"

if you additionally want to specify the time.

find . -mindepth 1 -maxdepth 1 -mtime -7  
find . -type f -newermt '11/25/2020 0:00:00'

If you don't limit the search to files when it finds a matching directory it will list every file within it. Be sure to use the "-type f" for files.

find . -type f -mtime -30

Now with some fancy formatting

find . -type f -mtime -30 -printf "%M %u %g %TR %TD %p\n"

Last, this working example was used to check a public share on a file server and generate a report, showing only files modified after the specific date.

find . -type f -newermt '11/25/2020 0:00:00' > ~/public-drive-newer.txt

[TEST IF PORT IS OPEN, CONNECT TO PORT FROM CLIENT (with netcat) ]

On system A you may want to connect to system B via a specific software that uses a specific port. You may also be trying to diagnose a connection issue. For example, say you want to know if port 6000 is open, as in not blocked on the remote system then you do a test with netcat. The netcat command is simply 'nc'.

On the remote host type:

nc -l 6000

Now netcat is listening on port 6000

On the local host you can simply use telnet to send text.

telnet remote-ip 6000

Once connected type some characters and see if they appear on the remote. If no connection then you are blocked or remote is not listening. Otherwise you will see your text echo'd on the remote.

[MEASURE THE STRENGTH OF WIFI CONNECTION]

To measure the strength of the wireless connection from CLI

watch -n1 iwconfig

Shows link quality as well as signal level.

[DISPLAY RESOLUTIONS AVAILABLE FOR MONITOR OR SET FROM COMMAND LINE]

Use the xrandr command. Xrandr is used to set the size, orientation and/or reflection of the outputs for a screen. It can also set the screen size.

If you type 'xrandr' and ENTER you will see info about your current display. See if you are using something like VGA-1, DVI-0, HDMI-1, DP-1, etc etc <- examples only

DO NOT TYPE: xgamma --output VGA-1 --brightness 0 (substitute VGA-1) for your display, this will make your screen black and you will see nothing. Here is a working example:

xrandr --output VGA-1 --brightness 0.75

Learn more

man xrandr

[ADJUST DISPLAY CONTRAST AND TINT FROM COMMAND LINE]

You can Adjust the Display With xgamma and xrandr from the command line. See xrandr above.

xrandr --output VGA-1 --gamma 1:1:1

Use the xgamma command. A gamma value of 1.0 is the default. A gamma value of 0.8 would give you more contrast. A value of 1.4 would be much less contrast. Example usage:

xgamma -gamma 0.8

xgamma - Alter a monitor's gamma correction through the X server. The gamma correction can either be defined as a single value, or separately for the red, green and blue components. Also: -rgamma -ggamma -bgamma

Learn more

man xgamma

[MONITOR USB PORTS FOR CONNECTING OR DISCONNECTING]

udevadm real-time monitoring of usb ports: To see if a device is plugged into USB or unplugged, real time monitoring showing when a USB device is connected or disconnected.

udevadm monitor --subsystem-match=usb

Does not require sudo

As soon as you connect any USB device, be it a USB flash drive or USB keyboard, mouse, etc details will be displayed. Also when disconnected.

[CLI SHELL AUTO COMPLETE COMMAND LINE PATH NO LONGER CYCLES]

This is actually a readline feature called menu-complete . You can bind it to tab (replacing the default complete) by running:

bind TAB:menu-complete

You probably want to add that to your ~/.bashrc. Alternatively, you could configure it for all readline completions (not just bash) in ~/.inputrc.

You may also find bind -p (show current bindings, note that shows tab as "\C-i") and bind -l (list all functions that can be bound) useful, as well as the bash manual's line editing section and readline's documentation. source: derobert on stackexchange


Related Pages

If what you're looking for isn't on this page, try some of these related pages:


 

 

Deprecateduck176.gif
Note: Some information on this page may be out of date, or no longer applicable to current use. You can help. Please contribute by registering your email address and updating this page with current information. The D.U.C.K. wiki was created to be a free informative place that allows an open exchange of accurate information.
Learn more...