How to CD to Your iCloud Drive on a Mac
How to CD to Your iCloud Drive on a Mac
Do you want to access your iCloud Drive using the Terminal app on your Mac? Apple gives users plenty of convenient ways of accessing iCloud Drive using the graphical user interface. Still, more advanced users may want to copy files to and from iCloud Drive from the Linux command line. Fortunately, it's easy to use the Linux cd command to switch to your iCloud Drive directory and manage files. You can also even edit your Bash profile to create an easy-to-remember alias to cut down on typing. This wikiHow article will teach you how to cd into your iCloud Drive folder in any version of macOS.
Things You Should Know
  • The path to iCloud Drive is "~/Library/Mobile\ Documents/com~apple~CloudDocs."
  • You can use standard Terminal commands to move, copy, remove, files, as well as create directories in iCloud Drive.
  • You can also edit the Bash profile to create an alias that will allow you to access iCloud Drive more easily in the Terminal.

CD to iCloud Drive

Open the Terminal. The Terminal has an icon that resembles a black screen with a white text cursor. Use the following steps to Open the Terminal: Click the magnifying glass icon in the upper-right corner to open the Spotlight search bar. Type Terminal in the search bar. Click Terminal.app.

Type cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/. This is the command to change the directory to your iCloud Drive. The "cd" at the beginning stands for "change directory." Whenever you want to change directories or folders in the terminal, type "cd" followed by the path of the directory or folder you want to change to. The "~" symbol at the beginning of the command is a shortcut for your home directory. Type "pwd" and press Return to find out your home directory (it's usually "users/" followed by your Mac username.) You can enter your home directory in place of "~". To navigate to a folder within your iCloud Drive, enter the name of folder at the end of the change directory command. For example, use "cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/Downloads" to navigate to your Downloads folder in iCloud Drive.

Press ⏎ Return. This executes the command and changes the directory to your iCloud Drive. To change back to your home directory, simply type "cd ~" and press Return.

Manage iCloud Files in Terminal

List all files and directories in your iCloud Drive. The command to list all files and folders in a directory is "ls." If you want to list all files and folders in your iCloud Drive, you would type ls ~/Library/Mobile\ Documents/com~apple~CloudDocs and press Return. Alternatively, you can use the "cd" command to change directories to iCloud Drive. Then just type "ls" and press Return.

Copy files to iCloud Drive. To copy a file from your Mac to your iCloud Drive, type "cp" followed by the path to the file you want to copy. Then enter the path to the iCloud Drive immediately after and press Return. For example, if you wanted to copy a file from your desktop to your iCloud Drive, you would type something like cp ~/Desktop/filename.txt ~/Library/Mobile\ Documents/com~apple~CloudDocs

Move a file to iCloud Drive. To move a file from your Mac to your iCloud Drive, type "mv" followed by the path to the file you want to move. Then enter the path to the iCloud Drive immediately after and press Return. For example, if you wanted to move a file from your pictures folder to your iCloud Drive, you would type something like mv ~/Pictures/filename.jpg ~/Library/Mobile\ Documents/com~apple~CloudDocs

Remove a file. To delete a file from your iCloud Drive, type "rm" followed by the path to the file you want to delete in your iCloud Drive and press Return. For example, you would type rm ~/Library/Mobile\ Documents/com~apple~CloudDocs/filename.zip to delete a zip file in your iCloud Drive.

Create a new directory. To create a new directory, use the "cd" command to change directories to the directory you want to create a new folder in. Then type "mkdir" followed by the name of the directory. For example, to create a directory called "Images" in your iCloud Drive, you would use the "cd" command to change directories to your iCloud Drive. Then you would type mkdir Images and press Return. You can also create and edit text files from within the Terminal.

Create an iCloud Drive Alias

Open the Finder Mac Finder. The Finder has an icon that resembles a blue and white smiley face. Click the finder icon in the Dock at the bottom of the screen to open the Finder. If you don't want to type the full path to your iCloud drive every time you want to access your files, you can create a shortcut alias so you only have to type a few letters.

Navigate to your Home folder. To do so, click your username in the menu bar to the left. This takes you to your Home folder.

Press ⌘ Command+⇧ Shift+Period to show hidden files. The file you need to edit is likely hidden. Press Command + Shift + Period (.) to show hidden files on a Mac.

Open the ".bash_profile" file in TextEdit. To do so, locate the ".bash_profile" file. Right-click (or hold Control and click) the file. Hover over Open With and select TextEdit.

Add a new alias at the end of the text file. Scroll down to the bottom of the ".bash_profile" file and add the alias command. You can replace the alias "icloud" with any alias you wish. However, your alias should be simple and easy to remember. Enter the following line of text at the end of your ".bash_profile" file. alias icloud='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs'

Save the document. To save the document, click File in the menu bar at the top. Then click Save.

Restart the Terminal. If you currently have a Terminal window open, go ahead and close it and then re-open it.

Use your alias to change the directory to iCloud Drive. With the alias saved to your ".bash_profile" file, you no longer need to enter the long "cd" command to change directories to iCloud Drive, you just need to enter your alias (i.e., "icloud") and press Return to change directories. This should save you a lot of time. You can add more aliases to your ".bash_profile" document to simplify other Terminal commands. Just use the following format: "alias ='Terminal command.

What's your reaction?

Comments

https://shivann.com/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!