su

Linux下su与su -命令的区别

我与影子孤独终老i 提交于 2019-12-25 17:04:07
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> su 后面不加用户是默认切到 root su 是不改变当前变量 su - 是改变为切换到用户的变量 也就是说su只能获得root的执行权限,不能获得环境变量 而su -是切换到root并获得root的环境变量及执行权限 语法: $ su [user_name] su 命令可以用来交互地更改你的用户ID和组ID。 Su是switch user 或set user id的一个缩写。这个命令让你开启一个子进程,成为新的用户 ID 和赋予你存取与这个用户ID 关联所有文件的存取权限。因此,出于安全的考虑,你在实际转换身份时,会被要求输入这个用户帐号的密码。 如果没有参数,su 命令将你转换为 root(系统管理员)。root 帐号有时也被称为超级用户,因为这个用户可以存取系统中的任何文件。也正是这个原因,许多人将su命令看成是 supper-user(超级用户)的一个缩写。当然,你必须要提供 root密码。 想要回到你原先的用户身份,不要再使用 su 命令,你只需要使用 exit命令退出你使用su命令而生成的新的对话进程。 $ su – username 一些配置文件是为你的对话线索而设立的。当你使用命令 su username时,你的对话特征和你原始的登录身份一样。如果你想要你的对话进程拥有转换后的用户

Java execute Linux commands that require su?

倖福魔咒の 提交于 2019-12-25 05:08:05
问题 What is the best way to run Linux commands that require "su" with Java? I want it to be very reliable, as for security goes I don't care much about it the system is not a production server. No one ever connects to the machine but myself. I thought about logging in as root so I don't have to deal with the su command and its disabled by default. I'm using Debian 6. The only thing is that one of my requirements is that the program should start after the normal user logs in without any farther

Copy files to another package folder (root, su)

人盡茶涼 提交于 2019-12-22 09:29:40
问题 I have my application's package (com.my.package) and i'd like to be able to copy some files (a.txt, b.txt and c.txt) to another package (data/data/com.another.package/files). Now i've tried a few things i found, but none worked. Any help please? 回答1: You need to get the Runtime and use the cat command. Runtime.getRuntime().exec("su cat filepath1 > filepath2"); 回答2: Runtime.getRuntime().exec("su cat filepath1 > filepath2"); creates an empty file for me too. I have to use su -c instead Runtime

msysGit sudo-like command

笑着哭i 提交于 2019-12-22 05:07:44
问题 If we open msysgit as administrator, we can use it as if we were root. However, it is often easier to open without administrator privileges. For example, for administrator privileges, you often have to go to Windows Explorer, the Start menu/screen, etc., and you can't do this from the taskbar. Sometimes, I'm too lazy to do all this, but I want to gain administrator privileges while in Bash. Is there a sudo - or su -like command or script, etc., for Git Bash? Going into cmd.exe , PowerShell ,

Rooting ICS emulator; pushing su fails with “Out of memory”

限于喜欢 提交于 2019-12-20 10:54:20
问题 I'm trying to root my ICS AVD, and have tried this: adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system adb push su /system/xbin/su adb shell chmod 06755 /system adb shell chmod 06755 /system/xbin/su It fails with the following error: failed to copy 'su' to '/system/xbin/su': Out of memory How can I fix this? 回答1: This blog explains the problem: To avoid the "Out of memory" error when trying to copy the su-executable to /system/bin , you need to start the emulator manually

How does Android SuperUser app detect that an app requests root?

◇◆丶佛笑我妖孽 提交于 2019-12-20 09:37:51
问题 I'm writing an app that will use su to execute some commands in the linux kernel. I was wondering how SuperUser figures out that the application is asking for root privileges ? Also, are there any known ways (through obfuscation) in which this check can be bypassed ? In other words: How does Android/(SuperUser) know that an app requires root privileges despite the fact that there are no permissions explicitly requested in the android manifest file. I'm asking this question from a security

Android Root execute su with parameters

放肆的年华 提交于 2019-12-20 05:38:05
问题 I ve got a problem, executing su with parameters (containing blank space?!). My Command.java looks like this: public class Command { Process process; public String executeCommand(String command) { StringBuffer output = new StringBuffer(); try { process = Runtime.getRuntime().exec(command); process.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = ""; while ((line = reader.readLine())!= null) { output.append(line + "\n"); } }

Run shell commands from android program

我只是一个虾纸丫 提交于 2019-12-19 03:22:50
问题 This question has been asked here before but the solutions provided are not working..I am trying to display the contents of /data/dalvik-cache folder. I know that to do this we need to become su. I even did that but still i am unable to execute a shell command.. package org.linuxconfidg.Example2; import android.app.Activity; import android.widget.*; import android.os.Bundle; import java.io.*; public class Example2Activity extends Activity { /** Called when the activity is first created. */

JSch - How to issue commands as the user I have switched to

时间秒杀一切 提交于 2019-12-17 21:29:53
问题 I am using Jsch to remotely connect to a Linux server from Windows 7. I have to (i) login to Linux server with my credentials (ii) switch to root using a pmrun command [this is the procedure in our environment], and (iii) execute su command to switch as "someuser" (iv) execute further commands as that "someuser" I completed the steps (i) and (ii). After completing step (ii), the InputStream from the channel shows the command-prompt as that of the root user. So I assume that I have become the

How do you find the original user through multiple sudo and su commands?

ⅰ亾dé卋堺 提交于 2019-12-17 06:25:17
问题 When running a script via sudo or su I want to get the original user. This should happen regardless of multiple sudo or su runs inside of each other and specifically sudo su - . 回答1: Results: Use who am i | awk '{print $1}' OR logname as no other methods are guaranteed. Logged in as self: evan> echo $USER evan evan> echo $SUDO_USER evan> echo $LOGNAME evan evan> whoami evan evan> who am i | awk '{print $1}' evan evan> logname evan evan> Normal sudo: evan> sudo -s root> echo $USER root root>