The Android Shell - Galaxy Grand Duos i9082 Q&A, Help & Troubleshootin

The Android Shell
A "shell" is a program that listens to keyboard input from a user and performs actions as directed by the user. Android devices come with a simple shell program. This shell program is mostly undocumented. Since many people are curious about it I thought I'd write up some documentation for it.
Currently this documentation is incomplete, sorry!
Common problems
The built-in shell has very limited error handling. When you type a command name incorrectly it will say "permission denied", even though the real problem is that it couldn't find the command:
$ dir
dir: permission denied <---- this is a misleading error message, should say 'dir: not found'
$ ls
... listing of current directory
The PATH variable
The Android shell will run any program it finds in its PATH. The PATH is a colon (':') seperated list of directories. You can find out what your shell's PATH is set to by using the built-in echo command:
$ echo $PATH
/data/local/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
Depending upon your shell, you may see a different result.
Built in Commands
Every shell has a few built-in commands. Some common built-in commands are:
echo -- prints text to stdout.
set -- sets shell variables
export -- makes shell variables available to command-line programs
cd -- change the current directory.
pwd -- print name of the current directory.
Commands
To find out what commands you have available to you, use the "ls" command on each of the directories in the PATH variable.
Finding documentation for the Android commands.
Many of the Android commands are based on standard Linux (or bsd) commands. If you're curious about a command, you can sometimes learn how it works by using the "man" command on a desktop Linux or OSX (Apple Macintosh) computer. The Linux or OSX version of the command may be different in details, but much of the documentation will still apply to the Android version of the command.
Another source of documentation for people without a Linux or OSX machine handy is to use a web browser and use a web search engine to search for the text: "man Linux command-name".
List of commands
The following is a list of the commands that are present on a Nexus S phone running an Android 2.3.3 "user-debug" build. Many of these commands are not present on a "user" phone. (They are missing from a "user" phone because they are specific to developing or debugging the Android operating system.)
$ ls /data/local/bin
/data/local/bin: No such file or directory
Notice that by default there is no /data/local/bin directory. You can create this directory using the "mkdir" command if you like.
$ ls /sbin
opendir failed, Permission denied
The /sbin directory exists, but you don't have permission to access it. You need root access. If you have a developer phone, or otherwise have root access to your phone you can see what's in this directory.
$ su
# ls /sbin
ueventd
adbd
# exit
$
Notice that the shell prompt changes from a '$' to a '#' to indicate that you have root access.
Notice also that neither of the /sbin commands are useful to the shell -- the adb and ueventd files are 'daemon' programs used to implement the Android Debugger "adb" program that is used by developers.
$ ls /vendor/bin
gpsd
pvrsrvinit
Vendor/bin is where device vendors can put device-specific executables. These files are from a Nexus S.
$ ls /system/sbin
/system/sbin: No such file or directory
This directory does not exist on a Nexus S.
$ ls /system/bin
am
am is the Android Activity Manager. It's used to start and stop Android activities (e.g. applications) from the command line. Type am by itself to get a list of options.
amix
aplay
Command line audio file player.
app_process
applypatch
Used to apply patches to android files.
arec
Command line audio recorder.
audioloop
bluetoothd
BlueTooth daemon
bmgr
Backup manager - type command by itself to get documentation.
bootanimation
Draws the boot animation. You may have to reset your phone to get out of this.
brcm_patchram_plus
bugreport
cat
Copy the contents of a file to standard output.
chmod
Change the mode of a file (e.g. whether it can be read or written.)
chown
Change the owner of a file.
cmp
Compare two files byte-by-byte
dalvikvm
The dalvik virtual machine. (Used to run Android applications.)
date
Prints the current date and time
dbus-daemon
dd
Convert and copy a file. By default copies standard in to standard out.
debuggerd
dexopt
df
Shows how much space is free on different file systems on your device.
dhcpcd
dmesg
dnsmasq
dumpstate
dumpsys
dvz
fsck_msdos
gdbserver
getevent
getprop
gzip
hciattach
hd
id
ifconfig
Shows the current configuration of network interfaces (IP, MAC address etc)
iftop
Shows the current processes using the network interfaces (top, but for networks)
ime
input
insmod
installd
ioctl
ionice
iptables
Manage the firewall
keystore
keystore_cli
kill
Send signals to processes.
linker
ln
Used to set up a file system link.
log
logcat
Prints the Android runtime log.
logwrapper
ls
Lists files.
lsmod
lsof
make_ext4fs
mediaserver
mkdir
Make a directory.
monkey
A program that sends random events, used to test applications. (Like having a monkey playing with the device.)
mount
mtpd
mv
Move a file from one directory to another. (Only on the same file system. Use "cat a > b" to copy a file between file systems.
nandread
ndc
netcfg
netd
netstat
newfs_msdos
notify
omx_tests
pand
ping
pm
pppd
printenv
ps
List active processes.
qemu-props
qemud
racoon
radiooptions
reboot
Reboot the device.
record
renice
rild
rm
Remove a file.
rmdir
Remove a directory.
rmmod
route
rtp_test
run-as
schedtest
schedtop
sdcard
sdptool
sendevent
service
servicemanager
setconsole
setprop
setup_fs
sh
showlease
sleep
smd
stagefright
start
Starts the Android runtime.
stop
Stops the Android runtime.
surfaceflinger
svc
sync
system_server
tc
testid3
toolbox
top
Shows which processes are currently using the most CPU time.
umount
uptime
Prints how long your device has been running since it was last booted.
vdc
vmstat
vold
watchprops
wipe
wpa_cli
wpa_supplicant
$ ls /system/xbin
add-property-tag
btool
check-lost+found
dexdump
dhdutil
hcidump
latencytop
librank
opcontrol
oprofiled
procmem
procrank
rawbu
scp
Secure copy program. (Used to copy files over the network.)
showmap
showslab
sqlite3
Used to administer SQLite databases.
strace
System trace command - use to see what system calls a program makes.
su
Start a shell with root privileges.
Versions of the Android Shell
Android 1.0 used a shell that had no tab completion or history editing.
Android 2.3 added history editing. You can for example use the up/down arrows to edit previous commands.

Related

Shell commands

Here you will find a list of some shell commands you can use on your android phone, either with a terminal emulator or over adb shell from your PC. I would recommend using connectbot as your terminal emulator.
The commands listed are in no way limited to what is described below, I am just scraping the surface here. For more information on these commands type ' --help' after your command, e.g. 'mount --help' or use google, most of these commands are exactly the same as what you would find on any Linux system, so you will find EXTENSIVE information on the web if you want to know more.
These commands work on my HTC Desire running Cyanogenmod 6 (Android 2.2), most, if not all of them should work on other devices and/or roms.
If you have any suggestions post them below or pm me and I will edit this post to include them.
Notes
Most of these commands require root privileges, type su first.
Everything after a # is a not and not a part of the command.
busybox
What it does
Provides a selection of commands not built into android by default.
Example(s)
busybox cp a b
Notes
busybox is included in most custom roms and has aliases set up so you do not need to type busybox before the commands eg, 'cp' is the same as 'busybox cp' in most custom roms.
cat
What it does
Prints the contents of a (text)file onscreen.
Example(s)
cat file
cd
What it does
Changes the current directory. You may find it easier to change to the directory you will be working in before issuing other commands so you dont need to include the full path in your commands.
Example(s)
cd .. # Go up 1 directory level, eg go from '/sdcard/download/ to '/sdcard'.
cd /sd-ext # Change to '/sd-ext'.
chmod
What it does
Makes a file executable
Example(s)
chmod 755 /data/bin/yourbin
cp
What it does
Copies files/directories
Example(s)
cp filea fileb
cp -rf directorya directoryb # Copy entire directory recursively and forces copy.
df
What it does
Displays information on all mounted filesystems (free space).
Example(s)
df -hm # Show disk usage in human readable format in Megabytes.
du
What it does
Diplays the size of files/directories.
Example(s)
du -md 1 # Prints the size of all directories in Megebytes.
du -sh file # Prints the size of file in human readable format.
du -sh directory # Prints the size of directory in human readable format.
export
What it does
Sets environment variables.
Example(s)
export PATH=$PATH;/sd-ext/bin;
free
What it does
Display the amount of free and used system memory
losetup
What it does
Associates loop disk images with loop devices.
Example(s)
losetup /sdcard/disk.img /dev/block/loop7
Notes
Android 2.2's implementation of apps2sd uses one loop device for each app saved to SD. There are 8 loop devives by default (loop0-loop7) so if you have 8 or more apps saved to SD you will not be able to use this command. There is no issue when using 'oldschool a2sd'
ls
What it does
List Directory contents.
Example(s)
ls -a # List directory contents including hidden contents.
mount
What it does
Mounts a filesystem.
Example(s)
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 # Remounts /system as writable.
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 # Remounts /system as read only.
mount -t ext2 /dev/block/loop6 /sdcard/disk # Mount loop6 on /sdcard/disk.
mount /sd-ext /sdcard/sd-ext # Mount /sd-ext on /sdcard/sd-ext.
Notes
On other devices it may be possible to mount disk images without going through losetup and using the option -loop in mount instead.
If you are having trouble with mount try using busybox mount instead, the busybox version seems more capable than the one shipped with Android.
mv
What it does
Move/rename files/directories
Example(s)
mv download/file stuff/file
mv picture4.jpg mydog.jpg
ping
What it does
Pings a server to check for conectivity.
Example(s)
ping -c 5 http://www.google.com # Ping google 5 times
Notes
if you do not include the -c option ping will work indefinatly.
pwd
What it does
Prints the current directory.
rm
What it does
Remove file/directory.
Example(s)
rm file
rm -rf directory # Delete a directory and its contents.
rmdir
What it does
Removes a directory
Example(s)
rmdir emptydir
Notes
If a directory has contents us 'rm -rf' instad.
su
What it does
Gives you root privelages.
touch
What it does
Makes an empty file
Example(s)
touch file.txt
wget
What it does
Download things from http or ftp.
Example(s)
wget http://www.google.com
Excellent, thank you.
Just what the doctor ordered for n00bs like me

[TUTORIAL] Everything about ADB - A reference for everyone

TUTORIAL - EVERYTHING ABOUT ADB - Fully Illustrated
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This will be part of a series of Tutorials compiled to better educate the Beginner-Intermediate users in XDA thread, and help them get rid of the "n00b" or "newbie" tag thrown at them!
1. WHAT IS ADB?
ADB or Android Debug Bridge is a command line program which is used to communicate with your Android phone (or an emulator used by programmers). The use of Adb for Android phone users ranges from using it as a tool to get the logcat- A realtime log of the Android system, which allows one to know the cause of any errors. It is very helpful to app hackers to know exctly what block of code does what, and to modify apps accordingly
2. HOW TO USE ADB - Running adb.exe
adb.exe is part of a package of tools called Android SDK or Software Development Kit. For users, the main applications useful for them are adb.exe, fastboot.exe and aapt.exe.
2.1 Installing adb.exe (Windows)
First, download the Android SDK package(exe file) from here The installer will prompt you to download and install the JDK (Java Development Kit) if you dont have it already installed
Next install the exe file and note the location where you install it to.
After install is over, use Windows explorer and navigate to the folder where you installed the SDK.
Double-click the SDK Manager.exe/SDK Setup.exe file at the root of the Android SDK directory.
This will open up the SDK Installation window, where you can choose from a list of packages to install
If you want to use only adb.exe and fastboot.exe, choose to install only the "Android SDK Tools" from the list (See fig 1 below)
That's it, adb.exe is now installed
Fig1:
Take a note of where you install it. It usually installs to a folder named Android-sdk-windows. Once you have it installed, you can copy the entire folder on a portable usb key/CD and use it on any other PC without a need to install it. I recommend that you make it a part of your Android CD (with rooting tools, unrooting tools, gold card etc).
2.2 Using adb.exe-Preparing your PC for running adb.exe quickly
Adding Adb to your Windows Path
Once installed, you should add the location of adb.exe to the* Windows Environment Path variable. To do that, go the subfolder of Android-sdk-windows where adb.exe can be found. Click on the Windows Explorer path displayed on Top, and copy the path to the Clipboard
Go to Start Menu, and Right click Computer, Choose Properties
Choose Advanced System Settings and then Environment variables
Now, add the Location you copied to the Clipboard earlier, to the end of the current path, after adding a ";"(without the quotes) to the end of the current path.
So, in my case, the current path shows:
c:\droidzone\windows; c:\droidzone\blahblah
It now becomes:
c:\droidzone\windows; c:\droidzone\blahblah;C:\Software\Phone\android-sdk-windows\tools
Hit Enter to everything.
From now, whenever you open a Command prompt in Windows, you will be able to execute Adb and Fastboot from there without needing to navigate to the folder where they are installed.
Next step: Elementary Adb commands
Don't forget to Hit the Thanks button to let me know that my posts helped you!
Elementary Adb commands
Ok, now that you've got adb all setup and prepared your computer to use it, you're ready to learn some basic adb commands. I'll be teaching some of them in this section.
Understanding how adb and the shell works
Let's first check if adb is working by asking it to communicate with our phone. Connect the phone with a usb cable to the PC. Note that you should have installed the HTC drivers already (They come with HTC Sync)
From your Windows Start Menu, Click on Run, then type the following and press enter. That should open a command shell:
Code:
cmd
Once there, type out the following:
Code:
adb devices
This will display a list showing the connected phones with their serial numbers (and emulators-But let us not worry about what these are, right now)
Great, now we have confirmation that adb is working! We're now ready to issue our basic commands.
First thing to note is the basic command to enter the Android custom linux shell. Like Windows has cmd.exe to enter the dos shell, the graphical eyecandy with Sense overlay that you see on your device has a custom linux kernel running, so basically the language of its shell is the Linux shell language.
Accessing the Linux terminal (adb shell) is what we do to issue commands. To enter the shell of our device, the basic command is:
Code:
adb shell
Immediately, you will get a prompt like this:
Code:
sh-3.2#
Now we can type out any (most) linux commands and these will be executed in our device.
The file system on Android is laid out over MTD partitions in your device's NAND (Internal memory), and the SD card. The Nand is strictly organized in a Linux system with Linux file permissions and ownership rights (Just know that these exist, for now)
So, right now, you will be dropped in the "root" of the filesystem, from where you can navigate to other places.
Note! An important difference between Linux and Windows is that while Windows uses the Backslash (\), Linux/Android uses the forward slash (/) to depict directory hierarchies. Another one you shouldnt forget is that in Linux/Android, a file named boot.img is different from Boot.img, BOOT.IMG and BoOt.img, while on Windows, they are all the same.
Click to expand...
Click to collapse
My tutorial is about adb commands, and not linux, so I'll give only a short summary of elementary linux commands below. I will expand the list and explanation for this at a later date if you require it:
pwd-Shows the current working directory
cp-copy a file
mv-move a file (copy a file and then delete the original file)
chmod-set file permissions
chown-set file ownerships
rm-delete a file
cd-change directory
rmdir-delete a directory
Click to expand...
Click to collapse
Elementary Adb commands
Installing applications with adb
You can install any apk from your PC to the phone very easily. Open a cmd shell, and then type in:
Code:
adb install
followed by a space. Now drag an apk file in Windows explorer to the shell we have opened. Immediately, the path of the file becomes inserted in our prompt that it becomes:
Code:
adb install C:\Desktop\TitaniumBackup.apk
assuming that the file TitaniumBackup.apk was present in the location C:\Desktop. Hit enter and you will notice that it gets installed.
Transferring files to the sdcard without connecting the device as Disk drive:
Code:
adb push C:\Desktop\TitaniumBackup.apk /sdcard/
will trasfer the file C:\Desktop\TitaniumBackup.apk to the root (main) directory of your sdcard. Likewise, you can transfer any file from the PC to any location on your device.
Eg: I want to transfer a file called wallpaper.zip to a location /data/local. The command would be:
Code:
adb push C:\Desktop\wallpaper.zip /data/local/
Contd..
Don't forget to Hit the Thanks button to let me know that my posts helped you!
More elementary adb commands:
Getting a file from your phone to your PC:
To get a file /system/etc/init.d/01data to your PC, you would type out the following:
Code:
adb pull /system/etc/init.d/01data
which will transfer the spcified file to the location on your pc where you have opened the cmd.exe shell.
Mounting the system partition as Read Write to transfer files to your /system partition:
Method 1:
Code:
adb remount
Method 2:
This can also be accomplished with the more advanced mount command in the adb shell. First we need to know the mount point of the partitions.
Type:
Code:
adb shell
mount
For me, it displays:
Code:
rootfs / rootfs rw,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
/sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /app-cache tmpfs rw,relatime,size=8192k,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
[B]/dev/block/mtdblock3 /system yaffs2 ro,relatime 0 0[/B]
/dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev,relatime 0 0
/dev/block/mtdblock5 /system/data yaffs2 rw,nosuid,nodev,noatime,nodiratime 0 0
/dev/block/mmcblk0p2 /data ext4 rw,nosuid,nodev,noatime,nodiratime,commit=50,bar
rier=0,stripe=64,data=ordered,noauto_da_alloc 0 0
/dev/block/vold/179:1 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,u
id=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset
=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:1 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relat
ime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,ioch
arset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
sh-3.2#
Note that the entry for system partition shows:
/dev/block/mtdblock3 /system yaffs2 ro,relatime 0 0
The ro means that /system is mounted as RO-i.e Read Only. The whole line means that the Nand MTD block device on /dev/block/mtdblock3 is mounted on the mount point /system, to use technical jargon.
We need to mount it as RW (Read Write)
The command is:
Code:
mount -o rw,remount /dev/block/mtdblock3 /system
This essentially mounts the /system as Read Write so that you can write to it (Normally you cant write to the /system partition), which is what "adb remount " also does. However the commands above can be executed from a Terminal Emulator application too.
Next: Getting an Adb logcat
Don't forget to Hit the Thanks button to let me know that my posts helped you!
Getting an adb logcat
Many a time, you might have heard people telling you to get a logcat to report your error with a Rom installation.
What is a logcat?
A logcat is a report from the Android logging system, which takes place in the background the whole time your phone is on. It starts the moment you switch on the phone, and continues till you shut it down completely. This log is extremely useful for finding out what went wrong with your system. It is useful to find out why your phone is having bootloops or force closes. It is infact useful for all errors!
How to get the logcat?
Basically, you can view the logcat log with the following command:
Code:
adb logcat
But that means getting overwhelmed by an endless haze of output flowing at a rate that you cant read and will overwhelm your command shell's capacity very soon.
So the system we normally use is to output the log to a file from which we can read later. This is done by the following command:
Code:
adb logcat > log.txt
My Technique
As a Rom developer and apk patcher, I have to constantly check for errors in my system. So I've devised an ingenous method to easily log logcat, and view them readily. I use a combo of commands executed in succession:
Code:
adb kill-server
echo "" > log.txt
start log.txt
adb logcat > log.txt
These commands essentially create a blank file named log.txt in the same path as the command shell you've opened. Then, it opens the file log.txt (which is blank at this point of time. Then it logs logcat output to that file. Once you refresh the opened file, it will show the output of logcat to this point of time. Refresh it once again, and it updates once more. You should install Notepad++ and associate .txt files with it, to get best results.
Instead of executing these four commands, you can download the batch file getlog.cmd and extract it from the zip file to the folder containing adb.exe. Once you type in the following command (from anywhere in Windows), you will achieve the same result as typing the four commands as above! Ingenious, eh?
Don't forget to Hit the Thanks button to let me know that my posts helped you!
Summary of other adb commands
The following is the partial list of commands supported by adb. You can obtain this list by the following command:
Code:
adb /?
Code:
C:\Users>adb /?
Android Debug Bridge version 1.0.26
-d - directs command to the only connected USB devic
e
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <serial number> - directs command to the USB device or emulator w
ith
the given serial number. Overrides ANDROID_SERI
AL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
connect <host>:<port> - connect to a device via TCP/IP
disconnect <host>:<port> - disconnect from a TCP/IP device
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> - push this package file to the device and i
nstall it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data
)
('-s' means install on SD card instead of inter
nal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)
adb bugreport - return all information from the device
that should be included in a bug report.
adb help - show this help message
adb version - show version num
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on th
e specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be u
pdated.
- If it is "system" or "data", only the corresponding partition
is updated.
I will add notes for these if you require them.
See the next post for Kernel errors..
How to get Kernel error messages
You can get debug messages from a running kernel with:
Code:
adb shell
dmesg
If you have reboots due to kernel panic, you should make users capture the last_kmsg log from /proc immediately on the reboot.
Note that dmesg can be disabled by the kernel maintainer, and hence some roms/kernels may not support the command.
Code:
adb shell
cat /proc/last_kmsg > /sdcard/last_kmsg
Should be done immediately after the reboot..Otherwise it will just get overwritten by newer kernel message.
So in brief, if you'd like to look at what the kernel is doing right now (any errors etc), you should use dmesg. If you want to know why your kernel rebooted, use the file proc/last_kmsg
It's extremely useful!
Don't forget to Hit the Thanks button to let me know that my posts helped you!
Guys, part of the tutorial is over.. Hope it is helpful. Will add more useful and advanced stuff later.. Hope it helps the newbies and some more seasoned users.
Feel free to ask any doubt that you think is silly, without fear of being ridiculed or being asked to search the thread! It should be related to adb though!
Impressive tutorial. You'll get my thanks when im back at my home pc
Sent from my HTC Desire S using XDA App
Nice tutorial bro. shoud be on dev section...???
coolexe said:
Nice tutorial bro. shoud be on dev section...???
Click to expand...
Click to collapse
Thanks bro.. I thought that might scare away newbies, plus since I havent done any actual development..
Droidzone said:
Thanks bro.. I thought that might scare away newbies, plus since I havent done any actual development..
Click to expand...
Click to collapse
Hi,
there is lots of thread in dev. section which doesn't belong to development...anyway nice tutorial for noobs...if possible add QtADB tool...
EDIT: Added to my threads
Will add a GUI section. Good tip.. It's a very useful tool
Hi there.
Well this is a nice tut for android newbies like me
can you also add a basic symlinking tut? (especially how to symlink a folder to an already existing symlink )
thanks!
jesseuy said:
Hi there.
Well this is a nice tut for android newbies like me
can you also add a basic symlinking tut? (especially how to symlink a folder to an already existing symlink )
thanks!
Click to expand...
Click to collapse
Does this answer your query?
From http://uw714doc.sco.com/en/SDK_sysprog/_Using_Symbolic_Links.html
Code:
[B]Creating symbolic links[/B]
To create a symbolic link, the new system call [URL="http://uw714doc.sco.com/en/man/html.2/symlink.2.html"]symlink(2)[/URL] is used and the owner must have write permission in the directory where the link will reside. The file is created with the user's user-id and group-id but these are subsequently ignored. The mode of the file is created as 0777.
CAUTION: No checking is done when a symbolic link is created. There is nothing to stop a user from creating a symbolic link that refers to itself or to an ancestor of itself or several links that loop around among themselves. Therefore, when evaluating a pathname, it is important to put a limit on the number of symbolic links that may be encountered in case the evaluation encounters a loop. The variable MAXSYMLINKS is used to force the error ELOOP after MAXSYMLINKS symbolic links have been encountered. The value of MAXSYMLINKS should be at least 20.
To create a symbolic link, the ln command is used with the -s option (see [URL="http://uw714doc.sco.com/en/man/html.1/ln.1.html"]ln(1)[/URL]). If the -s option is not used and a user tries to create a link to a file on another file system, a symbolic link will not be created and the command will fail.
The syntax for creating symbolic links is as follows:
ln -s sourcefile1 [ sourcefile2 ... ] target With two arguments:
[LIST]
[*] sourcefile1 may be any pathname and need not exist.
[*] target may be an existing directory or a non-existent file.
[*] If target is an existing directory, a file is created in directory target whose name is the last component of sourcefile1 (`basename sourcefile1`). This file is a symbolic link that references sourcefile1.
[*] If target does not exist, a file with name target is created and it is a symbolic link that references sourcefile1.
[*] If target already exists and is not a directory, an error is returned.
[*] sourcefile1 and target may reside on different file systems.
[/LIST]
With more than two arguments:
[LIST]
[*] For each sourcefile, a file is created in target whose name is sourcefile or its last component (`basename sourcefile`) and is a symbolic link to sourcefile.
[*] If target is not an existing directory, an error is returned.
[*] Each sourcefile and target may reside on different file systems.
[/LIST]
[B]Examples[/B]
The following examples show how symbolic links may be created.
ln -s /usr/src/uts/sys /usr/include/sys In this example /usr/include is an existing directory. But file sys does not exist so it will be created as a symbolic link that refers to /usr/src/uts/sys. The result is that when file /usr/include/sys/x is accessed, the file /usr/src/uts/sys/x will actually be accessed. This kind of symbolic link may be used when files exist in the directory /usr/src/uts/sys but programs often refer to files in /usr/include/sys. Rather than creating corresponding files in /usr/include/sys that are hard links to files in /usr/src/uts/sys, one symbolic link can be used to link the two directories. In this example /usr/include/sys becomes a symbolic link that links the former /usr/include/sys directory to the /usr/src/uts/sys directory.
ln -s /etc/group . In this example the target is a directory (the current directory), so a file called group (`basename /etc/group`) is created in the current directory that is a symbolic link to /etc/group. ln -s /fs1/jan/abc /var/spool/abc In this example we imagine that /fs1/jan/abc does not exist at the time the command is issued. Nevertheless, the file /var/spool/abc is created as a symbolic link to /fs1/jan/abc. Later, /fs1/jan/abc may be created as a directory, regular file, or any other file type. The following example illustrates the use of more than two arguments:
ln -s /etc/group /etc/passwd . The user would like to have the group and passwd files in the current directory but cannot use hard links because /etc is a different file system. When more than two arguments are used, the last argument must be a directory; here it is the current directory. Two files, group and passwd, are created in the current directory, each a symbolic link to the associated file in /etc. [B]Removing symbolic links[/B]
Normally, when accessing a symbolic link, one follows the link and actually accesses the referenced file. However, this is not the case when one attempts to remove a symbolic link. When the [URL="http://uw714doc.sco.com/en/man/html.1/rm.1.html"]rm(1)[/URL] command is executed and the argument is a symbolic link, it is the symbolic link that is removed; the referenced file is not touched.
[B]Accessing symbolic links[/B]
Suppose abc is a symbolic link to file def. When a user accesses the symbolic link abc, it is the file permissions (ownership and access) of file def that are actually used; the permissions of abc are always ignored. If file def is not accessible (that is, either it does not exist or it exists but is not accessible to the user because of access permissions) and a user tries to access the symbolic link abc, the error message will refer to abc, not file def.
[B]Copying symbolic links[/B]
This section describes the behavior of the [URL="http://uw714doc.sco.com/en/man/html.1/cp.1.html"]cp(1)[/URL] command when one or more arguments are symbolic links. With the [URL="http://uw714doc.sco.com/en/man/html.1/cp.1.html"]cp(1)[/URL] command, if any argument is a symbolic link, that link is followed. Suppose the command line is
cp sym file3 where sym is a symbolic link that references a regular file test1 and file3 is a regular file. After execution of the command, file3 gets overwritten with the contents of the file test1. If the last argument is a symbolic link that references a directory, then files are copied to that directory. Suppose the command line is
cp file1 sym symd where file1 is a regular file, sym is a symbolic link that references a regular file test1, and symd is a symbolic link that references a directory DIR. After execution of the command, there will be two new files, DIR/file1 and DIR/sym that have the same contents as file1 and test1.
[B]Linking symbolic links[/B]
This section describes the behavior of the [URL="http://uw714doc.sco.com/en/man/html.1/ln.1.html"]ln(1)[/URL] command when one or more arguments are symbolic links. To understand the difference in behavior between this and the [URL="http://uw714doc.sco.com/en/man/html.1/cp.1.html"]cp(1)[/URL] command, it is useful to think of a copy operation as dealing with the contents of a file while the link operation deals with the name of a file.
Let us look at the case where the source argument to ln is a symbolic link. If the -s option is specified to ln, the command calls the symlink system call (see [URL="http://uw714doc.sco.com/en/man/html.2/symlink.2.html"]symlink(2)[/URL]). symlink does not follow the symbolic link specified by the source argument and creates a symbolic link to it. If -s is not specified, ln invokes the [URL="http://uw714doc.sco.com/en/man/html.2/link.2.html"]link(2)[/URL] system call. link follows the symbolic link specified by the source argument and creates a hard link to the file referenced by the symbolic link.
For the target argument, ln invokes a stat system call (see [URL="http://uw714doc.sco.com/en/man/html.2/stat.2.html"]stat(2)[/URL]). If stat indicates that the target argument is a directory, the files are linked in that directory. Otherwise, if the target argument is an existing file, it is overwritten. This means that if the second argument is a symbolic link to a directory, it is followed, but if it is a symbolic link to a regular file, the symbolic link is overwritten.
For example, if the command line is
ln sym file1 where sym is a symbolic link that references a regular file foo, and file1 is a regular file, file1 is overwritten and hard-linked to foo. Thus a hard link to a regular file has been created.
If the command is
ln -s sym file1 where the files are the same as in first example, file1 is overwritten and becomes a symbolic link to sym. If the command is
ln file1 sym where the files are the same as in the first example, sym is overwritten and hard-linked to file1. When the last argument is a directory as in
ln file1 sym symd where symd is a symbolic link to a directory DIR, and file1 and sym are the same as in the first example, the file DIR/file1 is hard-linked to file1 and DIR/sym is hard-linked to foo. [B]Moving symbolic links[/B]
This section describes the behavior of the [URL="http://uw714doc.sco.com/en/man/html.1/mv.1.html"]mv(1)[/URL] command. Like the [URL="http://uw714doc.sco.com/en/man/html.1/ln.1.html"]ln(1)[/URL] command, [URL="http://uw714doc.sco.com/en/man/html.1/mv.1.html"]mv(1)[/URL] deals with file names rather than file contents. With two arguments, a user invokes the [URL="http://uw714doc.sco.com/en/man/html.1/mv.1.html"]mv(1)[/URL] command to rename a file. Therefore, one would not want to follow the first argument if it is a symbolic link because it is the name of the file that is to be changed rather than the file contents. Suppose that sym is a symbolic link to /etc/passwd and abc is a regular file. If the command
mv sym abc is executed, the file sym is renamed abc and is still a symbolic link to /etc/passwd. If abc existed (as a regular file or a symbolic link to a regular file) before the command was executed, it is overwritten. Suppose the command is
mv sym1 file1 symd where sym1 is a symbolic link to a regular file foo, file1 is a regular file, and symd is a symbolic link that references a directory DIR. When the command is executed, the files sym1 and file1 are moved from the current directory to the DIR directory so that there are two new files, DIR/sym1, which is still a symbolic link to foo, and DIR/file1. In UnixWare, the [URL="http://uw714doc.sco.com/en/man/html.1/mv.1.html"]mv(1)[/URL] command uses the [URL="http://uw714doc.sco.com/en/man/html.2/rename.2.html"]rename(2)[/URL] system call. If the first argument to [URL="http://uw714doc.sco.com/en/man/html.2/rename.2.html"]rename(2)[/URL] is a symbolic link, [URL="http://uw714doc.sco.com/en/man/html.2/rename.2.html"]rename(2)[/URL] does not follow it; instead it renames the symbolic link itself. In System V prior to Release 4, a file was moved using the [URL="http://uw714doc.sco.com/en/man/html.2/link.2.html"]link(2)[/URL] system call followed by the [URL="http://uw714doc.sco.com/en/man/html.2/unlink.2.html"]unlink(2)[/URL] system call. Since [URL="http://uw714doc.sco.com/en/man/html.2/link.2.html"]link(2)[/URL] and [URL="http://uw714doc.sco.com/en/man/html.2/unlink.2.html"]unlink(2)[/URL] do not follow symbolic links, the result of those two operations is the same as the result of a call to [URL="http://uw714doc.sco.com/en/man/html.2/rename.2.html"]rename(2)[/URL].
Thanks for adding the tut. Will be reading and will definitely try it out.
Thanks again!
Sent from my HTC Desire using XDA App
Thanks a lot for the tutorial. Basic stuff nicly explained. i tried the push method via adb to push a font into system/fonts directory still it says read only permission
C:\Users\Mayu>adb shell
# mount
mount
rootfs / rootfs ro 0 0
tmpfs /dev tmpfs rw,mode=755 0 0
devpts /dev/pts devpts rw,mode=600 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
none /acct cgroup rw,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,cpu 0 0
/dev/block/mtdblock0 /system yaffs2 rw 0 0
/dev/block/mtdblock1 /data yaffs2 rw,nosuid,nodev 0 0
/dev/block/mtdblock2 /cache yaffs2 rw,nosuid,nodev 0 0
/dev/block/vold/179:0 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,n
id=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,io
1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:0 /mnt/secure/asec vfat rw,dirsync,nosuid,no
000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp4
8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,size=0k,mode=000 0 0
Click to expand...
Click to collapse
error mesg
C:\Users\Mayu>adb push E:\soft\Android\Indic\DroidSansFallback.ttf \system\fonts
failed to copy 'E:\soft\Android\Indic\DroidSansFallback.ttf' to '\system\fonts':
Read-only file system
Click to expand...
Click to collapse
PS: pull works like charm. please guide me if u hav time. Thanks.
DroidMayu said:
Thanks a lot for the tutorial. Basic stuff nicly explained. i tried the push method via adb to push a font into system/fonts directory still it says read only permission
error mesg
PS: pull works like charm. please guide me if u hav time. Thanks.
Click to expand...
Click to collapse
Yup, on an s on system, even though system can be mounted as rewrite, writing isn't allowed. You have to execute the commands in recovery mode
Sent from my HTC Desire using XDA App
Great tutorial! Thanks for that, definitely noob friendly...
Have a question about the following,
DATAOPTS:
(no option) - don't touch the data partition
-w - wipe the data partition
-d - flash the data partition
I have the Samsung Galaxy S I9000 (not sure if that makes a difference) and if my screen breaks or i have some sort of hardware problem. After flashing the stock rom back on do i use the above commands to wipe the evidence of any programs that suggest the device was previously rooted. If so which one wipe or flash?
Thanks
Thank You!!!
Hey Droidzone,
I'm really in awe of you, and need to thank you for the amazing work you're doing here - at XDA.
I just can't find the thank you button on the forums.(I could be blind !!!)
Thanks a zillion!!!

[Q] Setting up aliases for shell commands

Hello,
I have a question about linux shell command aliases in Android:
Is it possible to set up permanent aliases that can be used from both a terminal emulator on the device as well as ADB?
When I define an alias using adb, its gone as soon as I exit that session... but I would really like to have some permanent aliases for things I often use...
For example: "ls -la --color=never" is a bit tough to type everytime, but otherwise the color codes will screw up the adb shell output...
Any help appreciated!
Found a solution.
If anyone is interested:
Download bash posted in this thread: http://forum.xda-developers.com/showthread.php?t=537827
Adb push this bash to /system/bin, set permissions to 755 and symlink ./sh to ./bash...
Actually, instructions are all in the other thread
Then you can put your bashrc file to /sdcard/bash_profile, done!
It took me some searching but I found out how. Just add your aliases to the bottom of /system/etc/mkshrc

[Q] How do you use this adb command?

http://forum.xda-developers.com/showthread.php?t=1178912
5. Run the following commands from your platform-tools directory.
Code:
> adb push fre3vo /data/local/tmp
> adb shell
$ chmod 777 /data/local/tmp/fre3vo
$ /data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
I am able to do "adb push fre3vo", "adb shell", and "chmod 777" without a directory. I tried adding my directory "C:\android-sdk_r16-windows\platform-tools" but it doesn't work, what do I do for "C:\android-sdk_r16-windows\platform-tools/fre3vo -debug -start FAA90000 -end FFFFFFFF"?
Edit: I just probably forgot how to add my directory correctly, could someone show me how? And how to use commands with it?
You would type in the command window "cd c:/(your directory)". Then whatever you type after that will take pplace in the directory you entered.
Sent from my HTC Desire Z using xda premium
Thanks, but it only works for the first command, but doesn't work for the last 2, I even deleted the fre3vo file from the platform-tools folder and put in the folder fre3vo in it instead, and they still do not work.
How do I add fre3vo to my directory correctly? Should the file or folder of fre3vo be in the platform-tools folder?
The fre3vo command is run on the phone via shell.
When you enter adb shell, it opens a prompt with $, this is the terminal for the phone itself. All you need to do it type in those commands.
Think of "adb shell" as "Start > Run > 'cmd' > enter" on Windows.
---------- Post added at 10:56 AM ---------- Previous post was at 10:51 AM ----------
UKTone said:
http://forum.xda-developers.com/showthread.php?t=1178912
5. Run the following commands from your platform-tools directory.
Code:
> adb push fre3vo /data/local/tmp
> adb shell
$ chmod 777 /data/local/tmp/fre3vo
$ /data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
I am able to do "adb push fre3vo", "adb shell", and "chmod 777" without a directory. I tried adding my directory "C:\android-sdk_r16-windows\platform-tools" but it doesn't work, what do I do for "C:\android-sdk_r16-windows\platform-tools/fre3vo -debug -start FAA90000 -end FFFFFFFF"?
Edit: I just probably forgot how to add my directory correctly, could someone show me how? And how to use commands with it?
Click to expand...
Click to collapse
I'm going to double post and give a run-down of what you are doing here as it sounds like you're confused.
"adb push fre3vo /data/local/tmp/fre3vo" - You're moving the fre3vo files from c:\blahblahblah\platform-tools to /data/local/tmp/fre3vo on the phone
"adb shell" - You are opening the phone's command line interface through adb (similar to what I said in my previous post).
"chmod 777 /data/local/tmp/fre3vo" - You are setting the read write permissions through the phones terminal for the file on the phone itself
"/data/local/tmp/fre3vo (insert extra commands)" - You are executing the fre3vo file with particular switches attached to the command.
after "chmod 777" I get:
"Usage: chmod <MODE> <FILE>
After "-debug -start FAA90000 -end FFFFFFFF" I get "-debug: permission denied" at the end.
Edit: rebooting phone and cmd, and about to try the other 5 -debug commands
Edit: This last time I just put in the commands without the directories, which seems to be the only way to get chmod 777 to work... You are correct I am confused, I would like to know what exactly to put into my cmd. Also forgot to put the file fre3vo back into platform-tools...
You have to specify the file you are changing permissions on. In this case it would be:
Code:
chmod 777 /data/local/temp/fre3vo
Essentially you are tell the phone: "Hey, that fre3vo file at /data/local/tmp location needs to have read/write access set to 777"
biohazrd51 said:
You have to specify the file you are changing permissions on. In this case it would be:
Code:
chmod 777
Essentially you are tell the phone: "Hey, that fre3vo file at /data/local/tmp location needs to have read/write access set to 777"
Click to expand...
Click to collapse
How?
Also "chmod 777' only works without a directory for me "adb push fre3vo" works without, and with both "cd /data/local/tmp" and "cd C:\android-sdk_r16-windows\platform-tools"
I'm sorry if it seems I a being difficult, I really can't figure this out.
Edit: also it's the "-debug -start FAA90000 -end FFFFFFFF" command that gives me a permission denied, not "chmod 777""
Edit: Reread your other post, I tried "chmod 777 cd /data/local/temp/fre3vo" but it tells me there is no such file or directory.
Ok, i think i understand the problem.
You think that the $ prompt is still the windows prompt, it isn't.
When you are at the command line in windows at the location "c:\blahblahblah\platform-tools" and type in the command "adb shell" you leave the windows command line and enter the Linux/Android command line for the phone. At that point you are entering linux commands, not windows, and they are executing on the phone (you're just viewing it on the PC). Linux commands don't need you to specify folder location like platform-tools.
So when I say
Code:
chmod 777 /data/local/tmp/fre3vo
It means "hey linux/android on the phone, take the Fre3vo file (/fre3vo) at location /data/local/tmp (on the phone) and give it permissions (chmod is the command giving permissions) equal to 777 (read/write/execute)"
chmod = the command to change permissions
777 = the permissions of read/write/execute
/data/local/tmp = the location of the file on the phone (it was moved there by adb push /data/local/tmp/fre3vo)
/fre3vo = the particular file you want to change the permission.
Make sense?
Ok I saw your post about file not found. Exit out of the windows command line and move the fre3vo file back to c:\blahblahblah\platform-tools like you had earlier. Start back over with the adb push command.
Code:
adb push c:\blahblahblah\platform-tools\fre3vo /data/local/tmp/fre3vo
adb = android debugger
push = move the file (from) location (to) location
c:\blahblahblah\platform-tools\fre3vo = location and actual file on the PC
/data/local/tmp/fre3vo = location on the phone you want the file moved to
When it moves successfully you should see something to the effect:
Code:
Fre3vo (275Kb/s)
Yes and no. So after the adb shell I am still supposed to be entering the commands on the cmd correct? Without any directories then? So just "$ chmod 777" but what about the "-debug -start FAA90000 -end FFFFFFFF" there are 5 others I haven't tried yet?
Also trying to add the directory "/data/local/tmp" or "cd /data/local/tmp" makes it fail everytime.
Also I am on the homescreen/standby, should I be somewhere else on the phone, like bootloader or something?
UKTone said:
Yes and no. So after the adb shell I am still supposed to be entering the commands on the cmd correct? Without any directories then? So just "$ chmod 777" but what about the "-debug -start FAA90000 -end FFFFFFFF" there are 5 others I haven't tried yet?
Also trying to add the directory "/data/local/tmp" or "cd /data/local/tmp" makes it fail everytime.
Also I am on the homescreen/standby, should I be somewhere else on the phone, like bootloader or something?
Click to expand...
Click to collapse
I don't think it matters where you are at on the phone.
Yes you would just enter commands like "chmod 777 /data/local/tmp/fre3vo" ($ is something that does not need to be entered).
I'm going to be away from the computer for about an hour. You may want to hop on IRC (do a search for it in these forums) and see if anyone there can walk you through it, otherwise ill be back later.
Sent from my HTC Vision using xda premium
Alright cool, thanks man, sorry if I gave you a headache lol.
And yeah I know, I was just adding that so you know I wasn't doing it before adb shell
No problem. The system ill be at has the sdk installed so I can take screenshots and load them.
Sent from my HTC Vision using xda premium
http://i242.photobucket.com/albums/ff137/UKTone/g21.png
http://i242.photobucket.com/albums/ff137/UKTone/g22.png
These show some of what I've been trying.
You don't need the "cd" before /data/local/tmp/fre3vo
Sent from my HTC Vision using xda premium
http://i242.photobucket.com/albums/ff137/UKTone/g23.png
http://i242.photobucket.com/albums/ff137/UKTone/g24.png
1. I tried without the cd, it doesn't seem to work without it...
2. fre3vo, should the file or the entire folder be in the platform-tools folder?
3. When you told me to do the irc thing, I downloaded mIRC, but while installing it said I didn't have permission to install, so I had to close and right click and run as administrator. This could be a possible problem? And any idea how to fix it?
Edit: By #3 I am thinking maybe this same permission problem is causing "-debug -start FAA90000 -end FFFFFFFF" to give me a permission denied response.
Honestly its been so long since I've done this I don't remember if it is file or folder. Let me review it all and let you know.
Additionally, here are some screenshots of the commands (ignore the prompts beforehand as my setup is probably a bit different than yours, only the commands matter).
By the way, what guide are you using?
Yeah I figured, it's been out for a while.
http://forum.xda-developers.com/showthread.php?t=1178912 I was linked to this guide from this guide http://forum.xda-developers.com/wik...sion#Rooting_the_Vision_.28G2.2FDZ.29_and_DHD
Btw I can't see the screen shots.
To elaborate, place the fre3vo file inside of the fre3vo.zip file and the misc_version file inside the misc_version_01.zipfile in your platform-tools directory
Click to expand...
Click to collapse
My guess would be the files, not folders. You need to execute fre3vo, so it would be a file.
I've never done a downgrade, so someone else might be able to chime in with some experience.
I think you should restar. Push the files to the phone again. Then start adb shell. Then run chmod 777. And try running fre3vo again.
Sent from my HTC Desire Z using xda premium
@ l337m45732 Still gives me a permission denied and I looked here:
http://forum.xda-developers.com/showthread.php?t=1411597
Am I supposed to put superuser on my phone first? If so do I just download it from the play store/market or use linda/astro with an .apk?
I get a permission denied when trying su.
Edit: I think once I get past this permission issue, I will breeze through the rest of the stuff. Also I tried doing everything after unlocking and setting my screen timeout to 30 minutes, still got permission denies.
Edit: I opened SDK Manager and updated everything and now I get it saying ADB servers didn't ACK.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>adb shell cat /dev/msm_rotator
adb server is out of date. killing...
* daemon started successfully *
/dev/msm_rotator: invalid length
C:\Windows\system32>adb push fre3vo /data/local/tmp
adb server is out of date. killing...
ADB server didn't ACK
* failed to start daemon *
error:
C:\Windows\system32>adb push fre3vo /data/local/tmp
adb server is out of date. killing...
ADB server didn't ACK
* failed to start daemon *
error:
C:\Windows\system32>
I consider this progress since something other than no such file or directory didn't come up when I tried the directory without cd. I got an ACK from "adb shell cat /dev/msm_rotator" and the solution was to have my phone unlocked at least once/have it fully loaded up. Idk what the solution/problem is with "adb push fre3vo /data/local/tmp" is yet.
Edit: Now it's back to saying cannot stat 'fre3vo': No such file or directory
Edit: so much for progress :
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>adb shell cat /dev/msm_rotator
/dev/msm_rotator: invalid length
C:\Windows\system32>adb push fre3vo /data/local/tmp
cannot stat 'fre3vo': No such file or directory
C:\Windows\system32>adb push fre3vo
Android Debug Bridge version 1.0.29
-d - directs command to the only connected USB devic
e
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <serial number> - directs command to the USB device or emulator w
ith
the given serial number. Overrides ANDROID_SERI
AL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number
is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number
is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devic
es.
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> - push this package file to the device and i
nstall it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data
)
('-s' means install on SD card instead of inter
nal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)
adb bugreport - return all information from the device
that should be included in a bug report.
adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosy
stem] [<packages...>]
- write an archive of the device's data to <file>
.
If no -f option is supplied then the data is wr
itten
to "backup.ab" in the current directory.
(-apk|-noapk enable/disable backup of the .apks
themselves
in the archive; the default is noapk.)
(-shared|-noshared enable/disable backup of the
device's
shared storage / SD card contents; the defau
lt is noshared.)
(-all means to back up all installed applicatio
ns)
(-system|-nosystem toggles whether -all automat
ically includes
system applications; the default is to inclu
de system apps)
(<packages...> is the list of applications to b
e backed up. If
the -all or -shared flags are passed, then t
he package
list is optional. Applications explicitly g
iven on the
command line will be included even if -nosys
tem would
ordinarily cause them to be omitted.)
adb restore <file> - restore device contents from the <file> backup
archive
adb help - show this help message
adb version - show version num
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on th
e specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be u
pdated.
- If it is "system" or "data", only the corresponding partition
is updated.
environmental variables:
ADB_TRACE - Print debug information. A comma separated list
of the following values
1 or all, adb, sockets, packets, rwx, usb, sync
, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes prior
ity over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these de
bug tags are printed.
C:\Windows\system32>adb shell
$ chmod 777 /data/local/tmp/fre3vo
chmod 777 /data/local/tmp/fre3vo
Unable to chmod /data/local/tmp/fre3vo: No such file or directory
$ chmod 777
chmod 777
Usage: chmod <MODE> <FILE>
$ /data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
/data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
/data/local/tmp/fre3vo: not found
$ -debug -start FAA90000 -end FFFFFFFF
-debug -start FAA90000 -end FFFFFFFF
-debug: permission denied
$
Edit: only difference I see is the daemon started successfully and failed, the other had neither, restarting phone and unplugging and going to try again.
Edit: I'm so tired of trying this, is there another way? Mainly just trying to do this http://forum.xda-developers.com/wik...sion#Rooting_the_Vision_.28G2.2FDZ.29_and_DHD for the T-Mobile G2 and I was linked from that to this guide http://forum.xda-developers.com/showthread.php?t=1178912 please help.
Edit: http://theunlockr.com/2011/07/22/how-to-downgrade-a-gingerbread-t-mobile-g2-so-it-can-be-rooted/ :
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>cd C:\android-sdk_r16-windows\tools\
C:\android-sdk_r16-windows\tools>adb push fre3vo /data/local/tmp
683 KB/s (9796 bytes in 0.014s)
C:\android-sdk_r16-windows\tools>adb push misc_version /data/local/tmp/
1645 KB/s (589849 bytes in 0.350s)
C:\android-sdk_r16-windows\tools>chmod 777 /data/local/tmp/fre3vo
'chmod' is not recognized as an internal or external command,
operable program or batch file.
C:\android-sdk_r16-windows\tools>chmod 777 /data/local/tmp/misc_version
'chmod' is not recognized as an internal or external command,
operable program or batch file.
C:\android-sdk_r16-windows\tools>/data/local/tmp/fre3vo -debug
The system cannot find the path specified.
C:\android-sdk_r16-windows\tools>
Edit: It finally freaking worked:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>adb shell cat /dev/msm_rotator
/dev/msm_rotator: invalid length
C:\Windows\system32>adb push fre3vo /data/local/tmp
cannot stat 'fre3vo': No such file or directory
C:\Windows\system32>adb push fre3vo cd /data/local/tmp
Android Debug Bridge version 1.0.29
-d - directs command to the only connected USB devic
e
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is r
unning.
-s <serial number> - directs command to the USB device or emulator w
ith
the given serial number. Overrides ANDROID_SERI
AL
environment variable.
-p <product name or path> - simple product name like 'sooner', or
a relative/absolute path to a product
out directory like 'out/target/product/sooner'.
If -p is not specified, the ANDROID_PRODUCT_OUT
environment variable is used, which must
be an absolute path.
devices - list all connected devices
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number
is specified.
disconnect [<host>[:<port>]] - disconnect from a TCP/IP device.
Port 5555 is used by default if no port number
is specified.
Using this command with no additional arguments
will disconnect from all connected TCP/IP devic
es.
device commands:
adb push <local> <remote> - copy file/dir to device
adb pull <remote> [<local>] - copy file/dir from device
adb sync [ <directory> ] - copy host->device only if changed
(-l means list but don't copy)
(see 'adb help all')
adb shell - run remote shell interactively
adb shell <command> - run remote shell command
adb emu <command> - run emulator console command
adb logcat [ <filter-spec> ] - View device log
adb forward <local> <remote> - forward socket connections
forward specs are one of:
tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp - list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> - push this package file to the device and i
nstall it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its data
)
('-s' means install on SD card instead of inter
nal storage)
adb uninstall [-k] <package> - remove this app package from the device
('-k' means keep the data and cache directories
)
adb bugreport - return all information from the device
that should be included in a bug report.
adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosy
stem] [<packages...>]
- write an archive of the device's data to <file>
.
If no -f option is supplied then the data is wr
itten
to "backup.ab" in the current directory.
(-apk|-noapk enable/disable backup of the .apks
themselves
in the archive; the default is noapk.)
(-shared|-noshared enable/disable backup of the
device's
shared storage / SD card contents; the defau
lt is noshared.)
(-all means to back up all installed applicatio
ns)
(-system|-nosystem toggles whether -all automat
ically includes
system applications; the default is to inclu
de system apps)
(<packages...> is the list of applications to b
e backed up. If
the -all or -shared flags are passed, then t
he package
list is optional. Applications explicitly g
iven on the
command line will be included even if -nosys
tem would
ordinarily cause them to be omitted.)
adb restore <file> - restore device contents from the <file> backup
archive
adb help - show this help message
adb version - show version num
scripting:
adb wait-for-device - block until device is online
adb start-server - ensure that there is a server running
adb kill-server - kill the server if it is running
adb get-state - prints: offline | bootloader | device
adb get-serialno - prints: <serial-number>
adb status-window - continuously print device status for a specifie
d device
adb remount - remounts the /system partition on the device re
ad-write
adb reboot [bootloader|recovery] - reboots the device, optionally into the boo
tloader or recovery program
adb reboot-bootloader - reboots the device into the bootloader
adb root - restarts the adbd daemon with root permissions
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on th
e specified port
networking:
adb ppp <tty> [parameters] - Run PPP over USB.
Note: you should not automatically start a PPP connection.
<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] - Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
<localdir> can be interpreted in several ways:
- If <directory> is not specified, both /system and /data partitions will be u
pdated.
- If it is "system" or "data", only the corresponding partition
is updated.
environmental variables:
ADB_TRACE - Print debug information. A comma separated list
of the following values
1 or all, adb, sockets, packets, rwx, usb, sync
, sysdeps, transport, jdwp
ANDROID_SERIAL - The serial number to connect to. -s takes prior
ity over this if given.
ANDROID_LOG_TAGS - When used with the logcat option, only these de
bug tags are printed.
C:\Windows\system32>adb shell
$ chmod 777 /data/local/tmp/fre3vo
chmod 777 /data/local/tmp/fre3vo
$ /data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
/data/local/tmp/fre3vo -debug -start FAA90000 -end FFFFFFFF
fre3vo by #teamwin
Please wait...
Attempting to modify ro.secure property...
fb_fix_screeninfo:
id: msmfb
smem_start: 802160640
smem_len: 3145728
type: 0
type_aux: 0
visual: 2
xpanstep: 0
ypanstep: 1
line_length: 1920
mmio_start: 0
accel: 0
fb_var_screeninfo:
xres: 480
yres: 800
xres_virtual: 480
yres_virtual: 1600
xoffset: 0
yoffset: 800
bits_per_pixel: 32
activate: 16
height: 80
width: 48
rotate: 0
grayscale: 0
nonstd: 0
accel_flags: 0
pixclock: 0
left_margin: 0
right_margin: 0
upper_margin: 0
lower_margin: 0
hsync_len: 0
vsync_len: 0
sync: 0
vmode: 0
Buffer offset: 00000000
Buffer size: 8192
Scanning region faa90000...
Scanning region fab80000...
Scanning region fac70000...
Scanning region fad60000...
Scanning region fae50000...
Scanning region faf40000...
Scanning region fb030000...
Scanning region fb120000...
Scanning region fb210000...
Scanning region fb300000...
Scanning region fb3f0000...
Scanning region fb4e0000...
Scanning region fb5d0000...
Scanning region fb6c0000...
Scanning region fb7b0000...
Scanning region fb8a0000...
Scanning region fb990000...
Scanning region fba80000...
Potential exploit area found at address fbb66a00:1600.
Exploiting device...
C:\Windows\system32>
Thanks guys for your help. the first half from the unlockr website did the trick.

[Solved] Mount a blank.img formated to ext? to bypass permission limitations?

I was wondering if I could mount an empty.img file so that I could add executable into it and chmod 777 them or what ever the number is maybe 666.
Then I would add the location to my $PATH variable in the "/system/etc/mkshrc" file so I could execute those programs from any directory.
What say you?
Has this been done before?
It works!
Well, I wen ahead and tried it out, I figured "What the hell, its not like I have to format my sd card." It worked!
So what I did
1) I changed directories to Downloads. ("cd ~/Downloads")
2) I created a directory for my image in Downloads, and moved into it. (mkdir image && cd ./image)
3) I created an empty 4 gig image called apps.img using dd ("dd if=/dev/zero of=apps.img bs=1MB count=0 seek=4096")
4) I formated it to ext2 ("mke2fs -F apps.img")
5) I used adb to push it to my phone ("adb push ~/Downloads/image/apps.img /storage/sdcard0/Download/")
6) Then on my phone as su I mounted the image ("mount -o loop '/storage/sdcard0/Download/apps.img' '/data/local/mnt' ") {with single quotes around the directories, the double quotes wrap the whole actual command, you don't need them} [EDIT: I used bash on the phone to do this, ie I "su" [enter] ; "bash" [enter] ; "THE ABOVE COMMAND" [enter]
7) To test I used the python interpreter as my executable so I created a folder in /data/local/mnt called apps,(note* I should have made that folder on my pc before I pushed it to my phone to ensure that the foder was actually in the apps.img file.) I created two more folders "bin" and "lib" using "File Manager" on my phone. I then moved what I needed to run python into those folders (though you'll see I forgot something)
8) I added PYTHONHOME PYTHONPATH and added the bin folder I created to $PATH in the /system/etc/bash/bashrc file (Ask and I'll explain). If you don't have bash the mkshrc file is located "/system/etc/mkshrc" on your phone (if its Sprint SGSIII) adding environment variable there will accomplish the same thing, sorta.
9) I connected my phone to pc w/usb, opened up a teminal on pc, started an adb shell
10)........
Code:
[email protected]:~$ adb devices
List of devices attached
xxxxxxxx device
[email protected]:~$ adb shell
[email protected]:/ $ su
[email protected]:/ # bash
void endpwent()(3) is not implemented on Android
localhost / # which python
/data/local/mnt/apps/bin/python
localhost / # python
'import site' failed; use -v for traceback
Python 2.6.2 (r262:71600, Mar 20 2011, 16:54:21)
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> import math
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named math
>>> import io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/io.py", line 63, in <module>
ImportError: No module named _fileio
>>>
localhost / # exit
[email protected]:/ # ^D
[email protected]:/ $ ^D
[email protected]:~$
I'm thinking that if I can get my mkbootimg tools to work, I would mod an init script to mount the apps.img and then create links for each file in say '/mnt/apps/bin' create a link*in '/system/bin'. this should allow for phones with small or near full system partition install stuff like busybox or your own pprograms. More usefull for a developer.
I wanna try this with pythonforandroid, if I can make python and its modules. accessible during early init or just before the boot process finishes in general, and use it to run python, maybe python can handle boot in a different way, or maybe just one specific. function you might needs.
one big question I have. Does the pythonforandroid interpreter run ontop of the D VM?
Edge-Case said:
I'm thinking that if I can get my mkbootimg tools to work, I would mod an init script to mount the apps.img and then create links for each file in say '/mnt/apps/bin' create a link*in '/system/bin'. this should allow for phones with small or near full system partition install stuff like busybox or your own pprograms. More usefull for a developer.
I wanna try this with pythonforandroid, if I can make python and its modules. accessible during early init or just before the boot process finishes in general, and use it to run python, maybe python can handle boot in a different way, or maybe just one specific. function you might needs.
one big question I have. Does the pythonforandroid interpreter run ontop of the D VM?
Click to expand...
Click to collapse
I don't think so. All command-line programs I know of interface directly with the kernel.
Sent from my S3 on Sense 5 (you jelly?)
CNexus said:
I don't think so. All command-line programs I know of interface directly with the kernel.
Sent from my S3 on Sense 5 (you jelly?)
Click to expand...
Click to collapse
So getting an extended set of Linux (kernel) cli programs working with Android (kernel) is a matter of having the nessissary libraries, kernel prereq., and being compiled for the target processor?
From what I have read, the Android kernel has been cut back so far from the original Linux kernel that its difficult to port "Linux apps" to Android. Something about a slimmed down version of the GNU C/C++ libraries and the Android kernel being designed to run mostly Dalvik.
I haven't tried directly running any "Linux app" (already compiled for arm) on Android yet, but my game plan for that test was to load up an .img file with the nessissary execs, libs, config, etc files (as ext3 this time) and running some scripts that get the paths variables set up and then execute the script, I wrote a short Bash script that sets up python variables and adds others to PATH etc, and it worked, I had python on the img and the img mounted to /mnt/myside and python ran but with some errors, I need to get the variables right, its driving me mad, if its not this its that, last time it was the basic "help()" command not being declaired or something.
Well thats my plan, either these "Linux apps" run on Android without problem or I am going to A) write my own kernel to be compatible with Android/ cli Linux or I am going to get as much source code as I can and practice the art of compiling against Android and/or patching the code when/where nessissary.
We'll see what happens, I've done enough today/night.

Categories

Resources