Script Commands for Linux Devices

Use the options and examples below to help you create your own powerful script commands.

Note: Not all script commands are compatible with all devices within a platform. Limitations are noted in the table entries.

Legend

Format Meaning
text Enter the command exactly as shown.
text Replace with the requested information.
[text] Information contained within square brackets is optional to the command.
text|text Choose one of the options separated by the vertical pipe.

Commands

Command Syntax
cat

Displays contents of the specified file.

cat filename

Example

To see the contents of snickers.xml:

cat snickers.xml

cd

Changes the current directory.

cd [directory]

Example

To change to the Chocolate directory:

cd Chocolate

chmod

Modifies user access and permissions.

chmod [+|-|=] [u|g|o|r|w|x] filename

Where

  • + sets a permission
  • - removes a permission
  • = affects a permission
  • u means user
  • g means group
  • o means an entity other than a user or group
  • r denotes the read permission
  • w denotes the write permission
  • x denotes the execute permission

Example

To give the current group the permission to modify nutmeg.txt:

chmod g+w nutmeg.txt test

To change file permission to read, write and execute test\test1\test2\test3 recursively:

chmod 777 nutmeg.txt

copy or cp

Copies one or more files to another location.

copy source destination

Example

To copy all files with the extension .txt from the C:\ to the temp directory on the device:

C:\tempt\*.txt 1:\temp

connect

Prompts the device agent to attempt to connect to the deployment server.

./mobicontrol -connect
del

Deletes a file or folder.

del filename

Example

To delete a file named skittles.jpg:

del skittles.jpg

To delete all files with the extension .jpg in the current directory:

del *.tmp

To delete a file named skittles.jpg, forcefully:

del -f skittles.jpg

To delete a folder named Wrigley:

del Wrigley/

disconnect

Prompts the device agent to disconnect from the deployment server.

./mobicontrol -disconnect
find

Finds a file on the device.

find [/S] [filename]

Where /S applies the search to any subfolders

Example

To search for all files with a .txt file extension including subfolders:

find /S *.txt

halt

Shuts down the device.

sudo halt
install

Installs software from the repository.

sudo apt-get packageName

Where packageName is the name of the application installer file on the device

Example

To install the Vim text editor:

sudo apt-get install vim

man

Displays the manual for a command.

man command

Example

To learn more about the chmod command:

man chmod

mkdir or md

Creates a new directory.

mkdir [drive:] path

Example

To create a directory named "test" from the current directory:

mkdir test

To create test\test1\test2\test3 recursively:

mkdir test \test1 \test2 \test3

move

Moves a file from specified source location to specified destination location.

Note: You can rename the file at the same time by specifying a name for the destination filename.
move [sourceFilePath] filename destinationFilePath [filename]

Example

To move the file test.bat:

move test.bat 2:\

move test.bat 2:\test.bat

To move and rename a file at the same time:

move 1:\test.bat 2:\test2.cmd

To move folder to root folder:

move Mars /

reboot

Reboots the device.

sudo reboot
rename

Renames a file or folder.

rename sourceFilename destinationFilename

Example

To rename the file test.txt to test.bak:

rename test.txt test.bak

reset

Performs a soft or hard reset of the device.

reset [/S | /H | /W | /E] [/delaysec]

Where

  • /S is the default option and soft resets the device. Any desktop remote control sessions will also be terminated.
  • /H is used to hard reset a device running on the Windows Pocket PC or Windows CE platforms. It clears any data stored in the volatile memory. On Windows Mobile 5.0 and later devices this is equivalent to a soft reset. The real-time clock may also reset depending on the device make and model.
  • /W is used to wipe data stored on the device and reset the device to factory default settings.
    Note: The wipe command is only supported on the Windows Mobile 5 operating system with AKU2 or later and newer versions of Windows Mobile.
  • /E is used to wipe data stored on the device and its external storage as well as reset the device to factory default settings.
  • /P is used to bypass factory reset protection. It is only supported on Android Enterprise Work Managed devices.

On Android Plus devices it is possible to specify a /delay parameter (in seconds): reset /S /delay 10

If /delay parameter is not defined, the default value is 5 seconds

Example

To soft reset a device:

reset /S

To reset an Android Plus device to its factory settings in 30 seconds:

reset /E /delay 30

rm

Deletes a file or folder.

rm filename

Example

To delete a file named skittles.jpg:

rm skittles.jpg

To delete all files with the extension .jpg in the current directory:

rm *.tmp

To delete a file named skittles.jpg, forcefully:

rm -f skittles.jpg

To delete a folder named Wrigley:

rm Wrigley/

rmdir or rd

Deletes a directory.

rmdir [/S] path

Where /S removes any subdirectories

On Android Plus and Linux devices, this command requires the /S option and will delete the specified item whether it is a directory or a file.

Example

To remove an empty directory named "test" from the current directory:

rmdir test

To remove a directory named "test" and all of its contents from the current directory:

rmdir /S test

To provide location:

rmdir /mnt/sdcard/test

setdate

Sets the date and time.

setdate date [time]

Where date is in the following format: mm-dd-yyy and time is in the following format: HH:MM:SS

Example

To set the date and time of the device

setdate 08-20-2016 13:32:00

shell

Launches the Linux shell.

shell
shutdown

Turns off the device.

shutdown [delay]

Where delay is a time period in seconds.

Example

To turn off the device:

shutdown

To turn off the device in 25 seconds:

shutdown 25

turnoff

Shuts down the device. You can specify a delay (in milliseconds) before shutdown.

turnoff [time]

Example

To turn off the device in 3.5 seconds:

turnoff 3500

uninstall

Removes the specified program from the device.

sudo dpkg -r program

Example

To remove the program Vim text editor:

sudo dpkg -r vim

writeprivateprofstring

Saves or deletes specified settings on a device.

See The writeprivateprofstring Command for more information.