MTF Notes
Last edited January 10, 2008
More by Scott C. »
 
 nm .m k[ U'  mm n......
file reading

read a certain line, e.g. the 1st:

perl -ne 'if(1..1) {print "1st line is $_"; last;}' filename
(1..1 is a range)

awk 'FNR == 1' filename

sed -n '1p' filename

"head -1 filename" to print that first line, but can't specify arbitrary lines from anywhere in the file
 comment?
ubuntu aliases

in .bashrc

uncomment:

#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi


create .bash_aliases

format:

alias ll='ls -l'

source .bashrc to load the config

http://www.arsgeek.com/?p=686 -- [search: ubuntu shell alias]
RootSudo

https://help.ubuntu.com/community/RootSudo

Example #2

sudo /etc/init.d/networking restart
  • NEVER use sudo to start graphical programs. You should always use gksudo or kdesu to run such programs, otherwise new login attempts may fail. If this happens and at login an error message reports: "Unable to read ICE authority file", log in using the failsafe terminal and execute the command below substituting user for your username.

rm /home/user/.{ICE,X}authority
  • To start a root shell (i.e. a command window where you can run root commands) use:

sudo -i
  • To login as another user (on the command line, use something like gdmflexiserver for a graphical login)

sudo -i -u username

Launch File Browser (Nautilus) as root:

(Alt-F2 -- shortcut to run application)

gksudo nautilus

http://www.psychocats.net/ubuntu/permissions  -- [search: ubuntu "file browser" copy /usr]
 
 Java on GNU/Linux

export CLASSPATH=.:~/src/java/example

Apparently has to be export for compile to work with imports.
Gnome Keyboard Configuration 

http://ubuntuforums.org/showthread.php?t=300381

In order to make Win + D, R and E to work, first go to System -> Preferences -> Keyboard (as bodhi.zazen said). Then click the Layout Options tab and then Alt/Win key behavior. Select Super is mapped to Win-keys.

Then go to System -> Preferences -> Keyboard Shortcuts and edit:

Home folder
Show the panel run application dialog
Hide all windows and focus desktop

ALT + arrow keys to switch workspaces

settings saved in ~/.gconfd/saved_state
 
Samba

Find Samba version?
http://lists.samba.org/archive/samba/2001-January/023500.html
smbd is on Fedora, but not on Ubuntu


sudo apt-get install samba smbfs
Setting up smbfs (3.0.22-1ubuntu4) ...

Ubuntu: mount -t smbfs  -o uid=scarpent,gid=scarpent,username=admin ...
 System/kernel version info:

uname -a : print all information

uname -r : print the kernel release

uname -v : print the kernel version

uname -o : print the operating system


Samba
 
http://www.nslu2-linux.org/wiki/HowTo/TroubleshootADriveMissingCondition

Had the same problems as described in the first entry.
I wanted to use disk1 to unsling. Disk1 was already formatted by the NSLU, but not recognized if plugged in after NSLU boot.
Firmware: V2.3R63. uNSLUng 6.8 beta.

The way I was able to unsling:
1)boot without disk
2)telnet to NSLU
3)attach disk (disk is powered off)
4)power on disk
5)type 'mount -t ext3 /dev/sdb1 /mnt/tmpmnt'. => you should see your data there
6)type 'umount /mnt/tmpmnt'
7)type 'mount -t ext3 /dev/sdb1 /share/hdd/data'
8)type 'mount -t ext3 /dev/sdb2 /share/hdd/conf'
9)reload the web-interface => you should see your disk there on port 1
10)proceed to unsling as described in the readme (in my case I had to type '/sbin/unsling disk1')
(replace sdb* with sda* if you want to use disk2 instead of disk1) 

http://www.nslu2-linux.org/wiki/Unslung/NewUsersGuide

ipkg  install samba

Installing samba (3.0.23d-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/nslu2/cross/stable/samba_3.0.23d-1_armeb.ipk
Installing popt (1.7-2) to root...
...
Configuring samba
The original samba version 2 config (/etc/samba/smb.conf) is no longer
working with this version of samba.
Please create a new samba version 3 config (/opt/etc/samba/smb.conf).
After verify your smb.conf file, modify and execute /opt/etc/init.d/S80samba
to activate the samba version 3.
Configuring update-modules
Configuring zlib

Edited according to:

http://www.nslu2-linux.org/wiki/Optware/Samba

Having problems after editing things but a restart seems to have taken care of things.

/opt/etc/samba/smb.conf is a link to a file that gets overwritten at startup.  Can break the link and make it a real file, but seems to work fine with the default.  S80samba changes persisted.

Couldn't connect with Windows but worked ok after restart (although windows complained about a duplicate name on the network.

Now can connect with mount -t cifs in Ubuntu, but similar permissions problem as in Fedora.





 
 NFS

The package nfs-utils is the package of utilities and configuration files to enable the kernel-mode NFS that is compiled into Unslung-able v3.16 and later.

Be sure that you have the portmap ipkg installed.

Then to use kernel-mode NFS, you first need to:

 ipkg remove nfs-server

if you have been using NFS previously and it is installed. Then you can:

 ipkg install nfs-utils
 
Change UID

find / -user uid# -print | xargs chown username 
Ubuntu VNC Server

http://ubuntuforums.org/showthread.php?t=122402

instructions a year old -- interface seems different in edgy

comments on vnc server in edgy:
http://ubuntuforums.org/showthread.php?p=2113441
http://grumpymole.blogspot.com/2007/02/edgy-and-feisty-vnc4server-still-not.html 


Updated instructions for Dapper (and Edgy):
http://ubuntuforums.org/showpost.php?p=1103220&postcount=112

Please note, these steps are only what you want to do if you had your VNC setup working under 5.10 and then you upgraded to 6.06 and it doesn't work anymore.

1. Log in to GNOME.
2. Click "System" -> "Administration" -> "Login Window"
3. Enter your password if necessary.
4. Click the "Remote" tab.
5. Under the "Style:" drop down box, choose "Same as Local".
6. Click the "Configure XDMCP" button and make sure "Honor Indirect Requests" is set to what you want it to be set to.  (According to original post -- should be disabled)
7. Click "close" twice.

See if this does it for you. Good luck!

Edit: Forgot to add that my VNC session doesn't seem to be resumable. I don't know if it's due to the Dapper upgrade or if I messed up somewhere else.


Howto points here:
http://easylinux.info/wiki/Ubuntu#How_to_add_extra_repositories

But what is that all about?

2/13/07 -- ah -- System --> Administration --> Synaptic Package Manager
Settings  --> Repositories

On system76 (Prometheus) --> All are enabled by default
On ibm T23 (Mercury) --> Community (universe) and restricted (multiverse) not enabled
(Which caused error when trying to install vnc4server via apt-get: E: Couldn't find package vnc4server)

Let's try this, changing to use the downgraded edgy vnc4server:

 sudo apt-get install vnc4server/edgy xinetd

Appears to have worked.

sudo vncpasswd /root/.vncpasswd

 sudo vi /etc/xinetd.d/Xvnc

instructions say:
sudo gedit /etc/xinetd.d/Xvnc
but I thought were supposed to use gksudo, but got funny message when tried that
(ah: http://www.psychocats.net/ubuntu/graphicalsudo)

service Xvnc
{
        type = UNLISTED
        disable = no
        socket_type = stream
        protocol = tcp
        wait = yes
        user = root
        server = /usr/bin/Xvnc
        server_args = -inetd :1 -query localhost -geometry 1024x768 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd
        port = 5901
}

(Much later, found /usr/share/X11/fonts/misc should be /usr/share/fonts/X11/misc

5. Restart xinetd (usually there is no need to reboot, but occasionally it might be required)

sudo /etc/init.d/xinetd stop
sudo killall Xvnc
sudo /etc/init.d/xinetd start

That's it! To test that this is working first try to connect from the same machine (the machine we just set up the VNC server on):

vncviewer localhost:1


scarpent@prometheus:~$ vncviewer localhost:1
VNC viewer version 3.3.7 - built Jul  4 2006 10:04:48
Copyright (C) 2002-2003 RealVNC Ltd.
Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
See http://www.realvnc.com for information on VNC.
ReadFromRFBServer: rdr::SystemException: read: Connection reset by peer (104)
 

After you've restarted the xinetd as shown in the step 5, you can check that xinetd is listening on port 5901 by doing this:

sudo netstat -tap | grep xinetd

And you should see a line like this: (your process ID doesn't have to be the same as mine 10932)

tcp 0 0 *:5901 *:* LISTEN 10932/xinetd

(not getting anything from netstat...)

Rebooting results in netstat returning:

tcp        0      0 *:5901                  *:*                     LISTEN     4268/xinetd 

But still connection reset by peer...

grep xinetd /var/log/syslog

see:
ubuntu xinetd[4829]: warning: can't get client address: Transport endpoint is not connected
ubuntu xinetd[4830]: warning: can't get client address: Transport endpoint is not connected
ubuntu xinetd[4268]: Deactivating service Xvnc due to excessive incoming connections.  Restarting in 10 seconds.
ubuntu xinetd[4268]: Activating service Xvnc


ps -ef | grep Xvnc

Doesn't show anything -- Xvnc is not running

http://ubuntuforums.org/showpost.php?p=688683&postcount=12

If it doesn't work it means that Xvnc wasn't started. So in that case I would suggest to try starting Xvnc manually (not from within xinetd) just to make sure it can run at all (we will use screen :2 so it doesn't overlap with the original Xvnc):

sudo Xvnc :2 -query localhost -geometry 1280x960 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd

(Later: again fixed fonts dir location)

Now, from another terminal try to connect:

vncviewer localhost:2

(orig. instruction had 1280x1024)


Got this when trying to start Xvnc:

Xvnc Free Edition 4.1.1
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 70000000, The X.Org Foundation


Thu Feb  8 10:30:38 2007
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5902
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/share/X11/fonts/misc, removing from list!

Fatal server error:
could not open default font 'fixed'

Trying:
sudo /usr/bin/Xvnc :2 -query localhost -geometry 1280x960 -depth 16 -once -fp /usr/share/X11/fonts/misc -dontdisconnect -nevershared -rfbauth /root/.vncpasswd

As suggested for an older vncviewer did not work either -- incorrect option



 Some stuff about xdmcp here:

http://ubuntuforums.org/showpost.php?p=1010469&postcount=99

gdm needs to be running, and xdmcp also needs to be enabled.

To start gdm use the following command on the machine you are trying to remote to ( this assumes you can either physically access it, or you have already "ssh"ed in Terminal)

sudo /etc/init.d/gdm start (you might then need to wait a minute, depending on the speed on your machine)

Next ensure that XDMCP is enabled

sudo gedit /etc/X11/gdm/gdm.conf
or
sudo nano /etc/X11/gdm/gdm.conf (if doing this through Terminal)

and find the [xdmcp] section at the end of the file
change

Enabled=False

to

Enabled=True

Then save and then best to reboot. of course if gdm is not loaded on boot, you will have to start it again


But the file warns about security of enabling this.


http://ubuntuforums.org/showpost.php?p=1108781&postcount=117

1. Enable XDMCP

Code:

sudo gedit /etc/gdm/gdm.conf

then find this rule:
# The greeter for xdmcp logins, usually you want a less graphically intensive
# greeter here so it's better to leave this with gdmlogin
# RemoteGreeter=/usr/lib/gdm/gdmlogin

remove the '#' in the last line so there should be:

# The greeter for xdmcp logins, usually you want a less graphically intensive
# greeter here so it's better to leave this with gdmlogin
RemoteGreeter=/usr/lib/gdm/gdmlogin


From this:
http://ubuntuforums.org/showpost.php?p=1508871&postcount=153

Got the idea that I might remove vnc4server/edgy and install vnc4server
Tried it, still get connection reset

Probably because xdmcp is not enabled


This:
http://ubuntuforums.org/showpost.php?p=1630733&postcount=166

I just wanted to post and update to this thread for anyone experiencing problems with Edgy (and maybe Beryl? not sure if thats what hosed me) setting this up.


In the /etc/xinetd.d/Xvnc file

change -fp /usr/share/X11/fonts/misc

TO

-fp /usr/share/fonts/X11/misc

This was my findings after ~2 hours of working away between x11vnc and vnc4server.

(seems to related to fonts error seen earlier)

yes!  That was wrong for Edgy

Restarted initd stuff but still couldn't grep for Xvnc.  Tried the manual Xvnc start and got:

scarpent@prometheus:~$ sudo Xvnc :2 -query localhost -geometry 1280x960 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd

Xvnc Free Edition 4.1.1
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 70000000, The X.Org Foundation


Thu Feb  8 11:17:35 2007
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5902
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
FreeFontPath: FPE "/usr/share/fonts/X11/misc" refcount is 2, should be 1; fixing.


vncviewer localhost:1 now prompts for password but then ReadFromRFBServer: rdr::EndOfStream
vncviewer localhost:2 vncviewer: ConnectToTcpAddr: connect: Connection refused
Unable to connect to VNC server

Let's enable xdmcp...

sudo vi /etc/X11/gdm/gdm.conf

Made:

[xdcmp]
Enabled=True

And uncommented RemoteGreeter line

Rebooted

still can't see Xvnc in grep

Still end of stream in vncviewer localhost:1

Try with Windows vncviewer and get password prompt, but then connection closed
(192.168.1.106::5901)

Still with end of stream errors.

http://ubuntuforums.org/showpost.php?p=1993196&postcount=208

Try without the query localhost:
sudo Xvnc :2 -geometry 1280x960 -depth 16 -once -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared passwordFile=/root/.vncpasswd

Xvnc Free Edition 4.1.1
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 70000000, The X.Org Foundation


Thu Feb  8 11:44:24 2007
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5902
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy


scarpent@prometheus:~$ sudo apt-get install vnc4server/edgy
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Selected version 4.1.1+xorg1.0.2-0ubuntu1 (Ubuntu:6.10/edgy) for vnc4server
Suggested packages:
  vnc-java
The following packages will be DOWNGRADED:
  vnc4server
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 3 not upgraded.
Need to get 0B/1011kB of archives.
After unpacking 81.9kB disk space will be freed.
Do you want to continue [Y/n]? Y
dpkg - warning: downgrading vnc4server from 4.1.1+xorg1.0.2-0ubuntu1.6.10.1 to 4.1.1+xorg1.0.2-0ubuntu1.
(Reading database ... 98245 files and directories currently installed.)
Preparing to replace vnc4server 4.1.1+xorg1.0.2-0ubuntu1.6.10.1 (using .../vnc4server_4.1.1+xorg1.0.2-0ubuntu1_i386.deb) ...
Unpacking replacement vnc4server ...
Setting up vnc4server (4.1.1+xorg1.0.2-0ubuntu1) ...


After downgrading, at at last, vncviewer localhost:1 works.  Got an error of some sort, and a warning that I was already logged in.

Let's try from Windows:

Yes!  Allows me to resume session also.

Can't seem to share Firefox when running :0 and :1  (Same as in Fedora)

Display looks ok -- but terminal window font not as good as direct login

vncviewer from Fedora also works fine

Was getting some crash when logging in :1 when already in :0, but not when logged out of :0.

Possible issue:
Was logged out of :0
Logged in and then out of :1
Display hosed on :0 -- bands of black and white and pixels
Remote :1 still worked -- eventually used "sudo shutdown -r now" 

Couldn't reproduce it right away after restart

And I followed that whole discussion, never realizing or thinking about the fact that my system76 is an AMD64.



 
bash

echo $SHELL
echo $BASH_VERSION

exit/logout/CTRL+D

~scarpent/tmp = ~/tmp

cd -      <cd to previous dir>

brace expansion:
echo {b{ed,olt,ar}s = beds bolts bars
echo {1..5} = 1 2 3 4 5
echo {a..c} = a b c
echo b{ar{d,n,k},ed}s
echo {a..z}{1..9}

redirection

command < filename
command > filename
cp equiv: $ cat < file1 > file2


quote single quote:
echo 'first part '\'' second part
first part ' second part


stty -a   (or stty all for solaris?)

CTRL-C        intr      stop current command
CTRL-D        eof      end of input
CTRL-\          quit    stop current cmd if CTRL-C doesn't work
CTRL-S       stop      halt output to screen
CTRL-Q                   restart output to screen
DEL or CTRL-?   erase      erase last character
CTRL-U         kill      erase entire command line
CTRL-Z         susp      suspend current command

^S and ^Q more of a nuisance these days -- screen will appear to be stuck if inadvertently hit ^S.


history editing
/string  search backward for string ???  CTRL+R seems to work
?string search forward for string

; redo last char-finding cmd
, redo last char-find in opposite direction

cmd complete
ESC, * to expand in current command
ESC, = to expand on different line

can expand $ shell variables and ~, and  @ (hostname)

~ invert case of current char  (can use repeat count)
# prepend # and send to history list

Files

.bash_profile
default system profile is /etc/profile

source or dot (., synonymous cmd) to execute commands in file

.bashrc
.bash_logout   (could be clean-up, etc.)


alias with no args lists all defined aliases

unalias "name" removes alias def for name

set / unset

HISTTIMEFORMAT="%y/%m/%d %T "
history

PS1 shell prompt variable

type <cmd>      find out path to command

hash -- shows hash table of cmd path lookups
hash <cmd> -- force cmd to be added to hash

CDPATH
e.g. CDPATH=~/some_dir

set cdable_vars
sd=~/some_dir
cd $sd

or use shopt

shopt
-p     list of settable options and current values
-s     sets each option name
-u      unsets each option name
-q     suppresses normal output - return status indicates if a variable is set or unset
-o     allows the values of the option names to be those defined for the -o option of the set command

shopt -s cdable_vars
cd sd

export var=value to make available to subprocesses

rc -- run commands (or so they say, from DEC operating systems)

functions

unset -f function_name
declare -f
   prints names and defs
declare -F
   just names

Shell order of precedence
1. Aliases
2. Keywords (function, others)
3. Functions
4. Built-ins (cd, type)
5. Scripts and executable programs (PATH env var)

type -all something
list aliases, etc, defined for something


positional parameters
$* $@    all params
$0 script name
$# number of arguments
$1 $2 $3 ...


env var IFS (internal field separator)
space TAB NEWLINE

 
misc commands

stat -- info about files and dirs including links 
ssh server

ubuntu

http://www.cyberciti.biz/tips/howot-install-ubuntu-linux-ssh-server.html

sudo apt-get install openssh-server

netstat -tulpn
Ubuntu disk space usage

GUI:  Applications --> Accessories --> Disk Usage Analyzer

df  standard file system disk usage

discus
The content on this page is provided by a Google Notebook user, and Google assumes no responsibility for this content.